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

Global boolean variables

Snowshoe_Bob
12-Amethyst

Global boolean variables

This is for Mathcad 15 although I would like to apply later to Prime 8.0.  My goals are for all of the boolean variables to be active for all portions of the sheet.  I want to defeat the top-down, left-right programming in the sheet.  See attached.

 

ACCEPTED SOLUTION

Accepted Solutions

YES!  Getting rid of the parenthesis allows the equation to work with the global variables.  

Thank YOU!

View solution in original post

12 REPLIES 12

Hi,

Mathcad takes a first pass through the worksheet.  Global variables are created in this pass.

A second pass through the worksheet creates other variables.

 

In the first pass global variable TR is created but it has as part of definition a normal variable ZIP that won't be created until the second pass.

Mathcad throws an error

 

Cheers

Terry

I don't follow you.


I want to defeat the top-down, left-right programming in the sheet. 

 


Why??

What would/should be the benefit of the global assignment?

 

A global assignment can only use constants or other globally assigned variables or functions. A global assignment CAN NOT USE variables which are defined using the normal assignment operator := even if the variable is defined in front of it.
Thats the reason for the error your got.

Terry tried to explain the reason for this behaviour. The sheet is first read by Prime from top down  only looking for global assignments. Normal assignments are ignored in this first pass (hence the error). Then in the second pass the normal assignments are considered and stored. That way its possible that a variable which is globally assigned can be used even in front of its actual definition.

 

To make your approach with the global assignment work you would have to also globally assign the variables Z1P, etc. which are used in the definition of TR. Not sure what the benefit of doing so would be, though.

I believe that I want to define various variables implicitly as they will be assigned further down in the sheet.  But I don't know how to do that in Mathcad.


@Snowshoe_Bob wrote:

I believe that I want to define various variables implicitly as they will be assigned further down in the sheet.  But I don't know how to do that in Mathcad.


Not sure what exactly an "implicit" variable definition would be. Would it make sense to define those variables globally so you can use them on top of the sheet before you define them?
Maybe a better approach is to define functions. and use them later when the variables are defined. Depends on what exactly you really try to achieve.

Thanks... I guess I've exhausted what Mathcad can do in this situation.  I was looking to define equations where variables in the equation would be defined later in the sheet.  Looks like one cannot do that in Mathcad.

Hi,

I was looking to define equations where variables in the equation would be defined later in the sheet. Looks like one cannot do that in Mathcad.

Of course you can do this with global variables.

Capture.JPG

What you cannot do is use a normal variable in the definition of a global variable because the normal definition does not exist until the second pass through the file..

Cheers

Terry

I see what you are doing.  And if I employ that same method and order in my boolean equation, I don't get and error.  But I don't get a result either.  See below

Get rid of the parenthesis and also post the Mathcad sheet rather than just a picture.

YES!  Getting rid of the parenthesis allows the equation to work with the global variables.  

Thank YOU!

ttokoro
20-Turquoise
(To:Snowshoe_Bob)

image.pngimage.pngimage.png

Thank You!

Announcements

Top Tags