Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mathcad15 - If statement false - > previously defined variable deleted or overwritten with 0 1

Status
Not open for further replies.

ZiggyD

Structural
Sep 16, 2019
2
Hello everyone,
I have a simple question: when I define an If statement in Mathcad 15 and this If statement is false, the variable used in the If statement is deleted or overwritten with 0. I would like the variable to stay unchanged when the If statement is false.
See for example this case:
Capture_ohkvby.jpg

Basically I would like the program to return the original value for the variable t (=2).
Any suggestions? Is there maybe some setting that can be changed?
Cheers!
 
Replies continue below

Recommended for you

Hi @IRstuff, thanks for the answer.
It is, although, interesting that if you just call the considered "outer variable" in the program (for whatever reason) before the If statement, the considered variable is not erased or overwritten with zero when the If statement is false:
Capture2_jo35vz.jpg
 
Why would it be? You've written an IF statement that has no ELSE, so nothing happens to t if the IF statement is false. This is one reason programmers avoid naming variables with the same name across function boundaries; it's bound to to confuse the reader and likely to cause mistakes.

TTFN (ta ta for now)
I can do absolutely anything. I'm an expert! faq731-376 forum1529 Entire Forum list
 
The most natural approach IMHO is this:
if_qtfs56.png

Sorry - the huge pic size is due to making the screenshot from a 4K display on a rather small notebook display with a rather large windows scale set. Other forum software would allow for resizing but I found no way to do that here. Am I missing something?
Would be annoying to have to manipulate the pic, resave it and then upload.
Are there plans to change the forum software to allow for directly copying pics from the clipboard w/o having to save them first? Would be much appreciated.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor