Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X
I am using an include statement to include calculations and values from a reference sheet in my main Mathcad document.
Is there a way to get access to variables defined in the parent document in the reference document? For example, if I define a variable called "mass" in the parent document, and then I have an expression in the referenced document that multiplies mass by 2, as in: double_mass := mass * 2, will that work?
Right now, I am only able to use variables in the reference sheet that have been defined in that sheet. I do note that functions and variables defined in the reference sheet are available in the parent sheet following the include statement, as expected.
Solved! Go to Solution.
The worksheet you include can use all variables from the parents sheet which are defined in front of the "Include" region.
But when you edit the include sheet, these variables will be unknown and so you will see an error message. Nonetheless the combination from parent sheet and included sheet will work OK.
Example;
Included sheet (Incl.mcdx) contains
It throws an error as of x not being defined.
The parents sheet works OK, though:
An included worksheet acts as if the containing commands would be written in the parents sheet at the position of the "Include".
The worksheet you include can use all variables from the parents sheet which are defined in front of the "Include" region.
But when you edit the include sheet, these variables will be unknown and so you will see an error message. Nonetheless the combination from parent sheet and included sheet will work OK.
Example;
Included sheet (Incl.mcdx) contains
It throws an error as of x not being defined.
The parents sheet works OK, though:
An included worksheet acts as if the containing commands would be written in the parents sheet at the position of the "Include".