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

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

Translate the entire conversation x

Reassign a Variable Based on a Condition

LearningENG11
8-Gravel

Reassign a Variable Based on a Condition

I have a ratio based on two variables: e' and d. If this ratio is larger than a condition, I want to assign d' to d and then recalculate the ratio. I want to keep the same variables; I just want the value of d' assigned to d and the ratio above recalculated. Is this possible? I have attached the sheet.

LearningENG11_0-1750967052496.png

 

ACCEPTED SOLUTION

Accepted Solutions

Simply assign the if-statement the variable d. You don't need the local(!) assignment d <-- d'.

Werner_E_0-1750968794458.png

Assignments inside a program always are local assignments and do not affect worksheet variables.

Only way to change a worksheet variable via a program is to assign it the output of a program.

Another way to achieve the same effect is

Werner_E_1-1750968966262.png

A more elaborate way is

Werner_E_2-1750969031367.png

 

 

 

 

View solution in original post

5 REPLIES 5

Simply assign the if-statement the variable d. You don't need the local(!) assignment d <-- d'.

Werner_E_0-1750968794458.png

Assignments inside a program always are local assignments and do not affect worksheet variables.

Only way to change a worksheet variable via a program is to assign it the output of a program.

Another way to achieve the same effect is

Werner_E_1-1750968966262.png

A more elaborate way is

Werner_E_2-1750969031367.png

 

 

 

 

Thank you for the help, much appreciated! I actually ended up doing it a different way, but this works too.

LearningENG11_0-1750974093518.png

 

SPaulis
14-Alexandrite
(To:LearningENG11)

Hi @LearningENG11 

 

Here are some addition simplifications you can use:

SPaulis_0-1750978601509.png

There is an Excel style "if()" function when you need a bit of brevity.  Also, if you have a lot of basic Y/N or Pass/Fail tests, you can make simple global functions and place them at the end.  It may be helpful because you do not want to have to keep writing the same code over and over and reduces errors and used real-estate.

 

 

Also, this is a preference of mine so ignore it if you prefer otherwise, I like to show D/C's because not only does it tell you if the check passes, but also how much reserve is left.  So I have a simple global function with gives more focus to the result than the if statements.  I modified your values a bit in the following example to demonstrate,  But these numbers show that the axial is very efficient and moment resistance only needs a bit of tweaking..  The big bold "✖" is a dead giveaway when something is not working 😉

SPaulis_2-1750979308291.png

This is my function in case you are curious:

SPaulis_5-1750979959320.png

 

 

 

 

 

 

 

 

 

Shawn P.
“It’s OK to fall in love with your heart. But, when it comes to making engineering decisions, don’t design with your heart.” – Blodgett, Omer W.
Werner_E
25-Diamond I
(To:SPaulis)

It's even shorter if you can do without the explicit “yes” and “no” 😉

Werner_E_0-1750980550847.png

 

SPaulis
14-Alexandrite
(To:Werner_E)

Yup, that is even shorter. 

 

In engineering, we like to put some sort of explicit confirmation, like a text.  You want the reviewer to recognize the common wording that their office employs.  My additional suggestion is that the coding for the 'verbose' result function does not get any more exciting as you review someone's calculation sheet.  And you do not want to bore the reviewer... at least not to death!  That is why a mundane function like that is better suited as a global function and defined at the end.

 

For future Prime versions, a real True/False number format, like in Excel, could also work in this situation.  I would imagine that custom number formats would be a much, much future feature for Prime.


Shawn P.
“It’s OK to fall in love with your heart. But, when it comes to making engineering decisions, don’t design with your heart.” – Blodgett, Omer W.
Announcements


Top Tags