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 PTC Community Badges. Engage with PTC and see how many you can earn! X

a nested mathcad worksheets

HusseinNaserald
1-Newbie

a nested mathcad worksheets

Hi,

Is it possible to call from within a worksheet, with parameters, to another worksheet that takes in as input the parameters of the call function and then runs and calculates the whole called sheet.

Thanks in advance,

Hussein

.

6 REPLIES 6

Yes, that's no problem.

Example:

Define CalledSheet with:

Define CallingSheet with:

You can expand this of course.

Success!

Luc

tietjee
14-Alexandrite
(To:LucMeekes)

I use the reference worksheet to store function and programs.  The reference worksheet is placed at the beginning of the "CallingSheet".  This does a several things:

1. Functions call be used anywhere in the "CallingSheet".  Documentation for the function will not clutter the "CallingSheet"

2. Programs take up a lot space and need documentation.

3. Consistent data and function between worksheets used in a single project.

The reference worksheet can also include unique constants (density air, seawater, etc.) listing of style examples, data...

Reference worksheets can be placed at the end of the "CallingSheet", all definitions have to globally defined.

StuartBruff
23-Emerald II
(To:LucMeekes)

LucMeekes wrote:

Yes, that's no problem.

Example:

Define CalledSheet with:

Define CallingSheet with:

You can expand this of course.

It's probably worth expanding upon the point that this isn't a true function call and that you can't repeatedly call the target ("function") worksheet within a loop.  The method effectively inserts the target worksheet into the calling worksheet (so it's more akin to a macro expansion in C than a function call).

A corollary of this is that the variables (parameters) must not be defined within the target worksheet, otherwise their values will override the calling worksheet parameters (eg, in your example, if CalledSheet.mcd defines a and/or b, then the Result won't change when you change a and b).

Stuart

We can do references on Web too (in Mathcad 15).

See please

WebRef.png

I assume you want to repeatedly call the worksheet, with different input parameters. If you have only one set of input parameters then you can just reference one worksheet in the other, as Luc shows. If you want to call the worksheet multiple times with different input parameters it's possible, but more difficult. You can use a scripted component in one worksheet to call the other worksheet via the automation interface. See the attached example.

Thanks fellows for your concise and helpful replies.

Best wishes,

Hussein

Top Tags