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 the Community Ranking System, a fun gamification element of the PTC Community. X

Conversion from Mathcad 15 to Prime, multiple if/otherwise statements

Joaberg
3-Visitor

Conversion from Mathcad 15 to Prime, multiple if/otherwise statements

Hi,


So i'm currently working on converting a worksheet from MC15 to Mathcad Prime and have ran into a problem with the conversion of MC15 "otherwise" expression to Prime "else" expression.

 

The "else" in Mathcad Prime seems to only account for the last if statement but in my case i have multiple if statements ending with an otherwise statement. How would i go about converting this to Mathcad prime in the easiest way?

 

See a dummy example attached.

 

Kind regards,

Johan

1 ACCEPTED SOLUTION

Accepted Solutions

Use "also if" instead of "if" for all subsequent if's after the first one.

Werner_E_0-1712747862348.png

 

BTW, its not necessary to write it as a function, but it was more convenient to do so for testing purposes.
But of course it works equally well the way you had set it up as a simple variable:

Werner_E_0-1712748243930.png

 

View solution in original post

3 REPLIES 3

Use "also if" instead of "if" for all subsequent if's after the first one.

Werner_E_0-1712747862348.png

 

BTW, its not necessary to write it as a function, but it was more convenient to do so for testing purposes.
But of course it works equally well the way you had set it up as a simple variable:

Werner_E_0-1712748243930.png

 

Okey great! I'll try that and see if it works out. Thanks!


Follow-up question:

Is there a command to add a line mid-program? For example inserting a new statement between the "if" and the "also if". I know that you would normaly use "enter" in prime but if i stand after the "1" i just get a new line in the if-statement and if i move once to the right it just highlights the also if-statement.

Editing programs with if..else or if ... also if can be quite demanding in Prime.

Actually Prime would not let you insert a line between "if..." and "also if ..." because this would break the connection between the "if" and the "also if" and unless the line you insert is also an "if" statement (Prime can't know what you intend to insert) the "also if" would be 'homeless' and a syntax error.

 

The best I could come up with to insert anothe "also if" statement between the "if" and the following "also if" ist this:

1) Put the cursor after the "1" in the "if" statement and press Ctrl-Enter to insert a line after the "1". Yes, it will be inside the "if"

2) In this newly created placeholder insert an "also if" command - either via the menu or by typing "alsoif" followed by pressing Ctrl-J

3) The "also if" will be in the correct position and all thats left to do apart from filling in the blanks in the newly created "also of" is to delete the placeholder after the "1" in the if-statement above.

 

 

 

Top Tags