Skip to main content
6-Contributor
January 23, 2025
Question

Does Include Worksheet open and run the included worksheet during calculate

  • January 23, 2025
  • 2 replies
  • 1292 views

If I use the Include Worksheet function in Mathcad Prime 10, will the worksheet called within the Include Worksheet function path then open and fully run, when calculate is commanded for the primary worksheet?  If I use the Include Worksheet function to call multiple worksheets throughout the primary worksheet, will each of the included worksheets be opened and fully run in sequence when the primary worksheet is calculated?

2 replies

23-Emerald IV
January 23, 2025

They should.

An included worksheet is calculated as if its contents was placed in the current worksheet at the point where it's referenced.

So all definitions of functions and variables in the included worksheet are done at the point of reference.

With possibly a few exceptions: A (re-)definition of ORIGIN inside the included worksheet might not override that of the including worksheet. Same for other built-in constants.

You also want to be cautious with two worksheets including each other...

 

Success!
Luc

6-Contributor
April 18, 2025

This did not work.  The first independent worksheet opened and ran properly, but none of the subsequent listed worksheets opened or ran.  So, not a solution for opening, running, and closing a series of independent sequential worksheets (and therefore generating the final tab spaced text data files and the solution set).

23-Emerald IV
April 19, 2025

What did not work. If possible show your worksheets, and explain what you expected and didn't happen.

Or else, create 3 worksheets:

Worksheet1.mcdx   contains

LucMeekes_0-1745056489447.png

Worksheet2.mcdx   contains

LucMeekes_1-1745056552052.png

(Yes, you get an error, because worksheet 2 doesn't know A. Ignore the error.)

Worksheet3.mcdx   contains:

LucMeekes_3-1745057042649.png

If you created the worksheets in this order Worksheet3 should already show:

LucMeekes_2-1745056961527.png

 

Success!

Luc

Community Moderator
February 26, 2025

Hi @MW_5360621,

 

I wanted to see if you got the help you needed.

If so, please mark the appropriate reply as the Accepted Solution. It will help other members who may have the same question.
Of course, if you have more to share on your issue, please pursue the conversation. 

 

Thanks,
Anurag

6-Contributor
April 26, 2025

 

 

Subject:

Re: Does Include Worksheet open and run the included worksheet during calculate

 

Date:

Saturday

April 26, 2025

 

Anurag,

None of the proposed solutions from Mathcad support, or the related community group, have worked properly.

 

The series of worksheets I have developed will go through a deep sea diving operation, and for each unique step in the sequence of events there is a worksheet, which calculates for that step in second by second time intervals - the partial pressures of the atmospheric gases being breathed within the diving chamber during that step - so that the diver blood gas & tissue gas levels can then be calculated later by a single standalone worksheet using the final data file generated by the sequence. If any single worksheet step inputs are changed (total step duration in seconds, diver work rate during the step, breathing gas constituent partial volumes during that step, etc.) - then all subsequent worksheets must also be reopened in sequence and recalculated - to determine the correct final data file needed for calculation of the diver blood / tissue gas levels – and later calculate the diver decompression schedule to be followed while the diver ascends to the ocean surface. Resulting data from the previous calculated worksheet, is automatically passed to the next worksheet by tab delimited text data files, and all data is numeric, in a matrix format with no embedded units. I have as many as 40 worksheets in a sequence, each with about 80 pages of math - that must be opened, calculated, saved, and closed exactly in sequence - while generating the new text data files for each worksheet. Changing a single input parameter in any worksheet can drastically change the final calculated decompression schedule. It is essential that these worksheets calculate fully, and in the proper sequence - to ensure the final diver decompression schedule generated is medically acceptable – or the diver is likely to be permanently disabled, and may die, during performance of the decompression schedule returning him to the ocean surface.

 

What I desperately need is a master worksheet or other program - that will automatically open, fully run (to calculate, and therefore read and write the worksheet text data files), save, and then close each identified Mathcad worksheet in sequence - for as many as 40 worksheets. It would also be good, if the master program gave me a progress message now and then. Right now, by hand, it takes me a full day of work - just to perform one complete sequence of worksheets. I use unique worksheet file names that follow a numbered sequence, which can be used to identify a worksheet, in a controlling script or program.

 

I require a program that can run this worksheet sequence in background, even if it takes a day (or evening), while I work on something else that does not use Mathcad (such as reports in MS Word or budgets in MS Excel). Presently, I am using Mathcad Prime 8, as that is the version other groups I work with are using. However, for an easy to implement solution to this problem, I would obtain a second personal license for Mathcad Prime 11, if required. My solution may use a new Mathcad worksheet with scripted specialized programming embedded in it, or a standalone program in another language that can control Mathcad – so long as it runs under the Microsoft Windows 11 Operating System. We are human medical physiologists, not software programmers, so any offered solution must be as easy to understand as possible.

 

Frankly, I am desperate for a solution – that actually works. This situation has severely limited the number of exploratory modeling scenarios we can accomplish for any potential dive – due to the budget and schedule constraints we must operate under.

Regards,

Mark

 

 

23-Emerald IV
April 27, 2025

Hi Mark,

I understand that you have multiple woirksheets that each calculate a section of the total problem and they must do that in sequence. That in itself should be perfectly possible using Prime, by either referencing each worksheet in sequence from within a master worksheet, or by the master worksheet referencing the latest worksheet which in turn references the one-but latest worksheet, which in turn references the two but lastest worksheet, which....

I suspect the main reason why your setup doesn't work as you hoped is because you communicate results from one worksheet as inputs to the next via an external file, your CSV file(s). If you keep all within Prime, e.g. communicate between worksheets via variables (scalars, vectors and matrices), the only other thing you need to ensure that evaluation takes place. This is best accomplished by structuring each of the worksheets through function(s) that you call in a subsequent worksheet. I suppose your separate worksheets aren't structured as such, so it will mean some rework preceded by rethinking. (The feature to allow a worksheet to be executed from within another worksheet as a function was asked for a couple of times, but so far it hasn't happened.)

Maybe it helps to describe the structure of your worksheets so we could help find a solution.

 

Regarding an extra license. You should only need an extra license (for a newer version of Prime) if you need any of the additional features of that new version. Note that you can run multiple instances of Prime simultaneously, so work on one worksheet on one instance of Prime while another instance of Prime is calculating on another is no problem.

Note that Prime is stricktly upwards compatible, meaning: Prime 11 will read worksheets created by Prime8, but any worksheets created/saved with Prime 11 cannot be read by Prime 8, and Prime 11 provides no possibility to save a Prime 8 version worksheet from within Prime 11. Any development you would do in Prime 11 could not be used by Prime 8. Considering that Prime 8 suffices for (the mathematics of) your problem I see no compelling reason to buy Prime 11.

 

Success!
Luc