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

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

If statement only giving second term's value. Works fine for coworkers!!!!

MA_9877245
1-Newbie

If statement only giving second term's value. Works fine for coworkers!!!!

I am using a simple if statement, regardless of the value of the defining variable it prints out the second term's value. However, if I give the file to a coworker the if statement works correctly. 

 

 

Unsuccessful things I have tried: 

* Two separate coworkers opened the file and it worked correctly for them without modifying anything

* Changed defining variable to something completely undefined elsewhere. 

* Rebooted my computer.

* Uninstalled v15.05 and reinstalled. 

* Uninstalled v15.05 and installed v14.35.

 

I am loosing my mind. I have no idea what else to do. 

2 REPLIES 2

I haven't got Mathcad to hand at the moment, but looking at your images, your "if" statement is incomplete.

 

If the condition is true, Mathcad will calculate the first expression.  However, it will then go straight on to calculate the next expression because you haven't told it to stop processing and return that value.

 

You have a couple of options.

1.  Put a return operator in your "if" expression, so that it looks something like "return <expr1> if <cond>".

2.  Put your second expression in an "otherwise" operator, "expr2 otherwise"

 

Stuart

LucMeekes
23-Emerald III
(To:MA_9877245)

Or you can use the if() function:

LucMeekes_0-1616446785315.png

 

Note that it is always better to attach the Mathcad worksheet.

 

Success!
Luc

Top Tags