cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Translate the entire conversation x

Does Include Worksheet open and run the included worksheet during calculate

MW_5360621
6-Contributor

Does Include Worksheet open and run the included worksheet during calculate

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?

8 REPLIES 8
LucMeekes
23-Emerald IV
(To:MW_5360621)

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

MW_5360621
6-Contributor
(To:LucMeekes)

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).

LucMeekes
23-Emerald IV
(To:MW_5360621)

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

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

MW_5360621
6-Contributor
(To:anursingh)

 

 

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

 

 

LucMeekes
23-Emerald IV
(To:MW_5360621)

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

MW_5360621
6-Contributor
(To:LucMeekes)

 

Subject:

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

 

Date:

Sunday

April 27, 2025

 

Luc,

Thank You for your potential answer to my problem. Unfortunately, it does not appear to be workable for the following reasons.

 

There are four Mathcad templates that are used as building blocks to create the entire series sequence of worksheets. Each worksheet is then tailored for that specific step during the initial setup, by the input of values into that worksheet’s variables, at the start of the worksheet. In addition, the worksheet must read the critical final calculated conditions from one of the previous worksheet’s data files, and input these values into additional variables as input parameters, as the worksheet calculation proceeds. The worksheet must then fully calculate, and generate the output data file that supports the next worksheet in the sequence, and the output data file that supports subsequent independent blood / tissue gas level calculations. The data files generated by each worksheet in the sequence are very large, due to the second by second (and sometimes ¼ of second) time slices required for medical accuracy, with a total time span of from 6 to 48 hours. For Mathcad to calculate a single worksheet in the sequence takes from 5 to 15 actual minutes, and requires a fast desktop computer setup as an engineering workstation, with at least 64 Gb of Dynamic RAM, and typically 128 Gb of Dynamic RAM. We cannot have multiple worksheets and data files in the sequence open and calculating at the same time – as we just do not have enough Dynamic RAM on a single engineering workstation. Why not link the engineering workstations on the network together to perform the operation? Again, we are not software programmers – and we do not have 40 engineering workstations available!

 

In addition, re-writing the Mathcad template files to improve functionality may be possible - but due to the fact that these calculations are life critical - the Deep Submergence Systems – Scope of Certification (DSS-SOC) re-review and re-certification process is quite arduous, expensive, and schedule consuming (so this is not our first choice of action).

 

Originally, we had to write these programs in FORTRAN and run them on a mainframe computer using the UNIX operating system - and we really do not want to go back to that!

 

It appears to me, that unless the feature you mentioned, which will allow a Mathcad worksheet to be fully executed from within another Mathcad worksheet as a function - is incorporated into a future Mathcad release – then for us, there is not a readily workable solution to our operational problem within Mathcad.

 

So, the other option is a standalone external program that will automatically open, run (fully calculate and therefore read and write the worksheet text data files), save, and then close - each file name identified Mathcad worksheet - in sequence - for as many as 40 worksheets. Can such an external program be written, and does Mathcad have the built-in functionality to execute the external program’s commands, when the external program runs? If so, what is the external programming language used, that runs under the Microsoft Windows 11 Operating System? Do any examples of this type of external program exist, that actually have been tested and therefore work? Sigh, I am becoming very tired of the many “answers” I have received - that not workable or practical.

Regards,

Mark

 

 

 

 

 

Hi Mark-

Seems like you have a big project, but it is not clear to me why luc's approach does not answer your original question. The attached zip file contains a master Prime 8 worksheet (Workspace 04.mcdx) which sequences 3 other worksheets. Each worksheet runs to completion prior to sequencing to the next. Simple dummy data are written by each worksheet to a CSV file, and these data are, in turn, read in by the next worksheet. Time stamps are used to verify that the execution sequence is correct and non-overlapping.

 

I have probably grossly oversimplified and do not pretend to comprehend your need for "templates" and if you require automatic restart at some point (in the worksheet sequence) if some worksheet detects an error. As Luc says, variables (like error flags) can easily be shared and can be used to abort the sequence at appropriate times.

 

You have provided an enormous description, but we in the community are simple folks and would prefer simple examples of what your needs are; that is, simplified worksheets that demonstrate your various needs.

 

Best wishes in your endeavors,

Roger

 

Announcements

Top Tags