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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

How to avoid wrong branching?

Efried
7-Bedrock

How to avoid wrong branching?

Hello,

it took quite a while before I found out the Mathcad 15 may have a big bug with if - otherwhise...

After introducing an one line statement using if, the next standard line holding an if-otherwise construct was not executed if the first condition was true. This happened two times in the code!

I have to say that this akward behavior makes it more likely to stay away from ptc as much as possible...

11 REPLIES 11

Can you provide an example? It seems ok to me.

Clipboard01.jpg

Mike

MikeArmstrong wrote:

...It seems ok to me...

For me too (Mathcad 15 M010).

Efried
7-Bedrock
(To:Efried)

two minutes after- the whole software crashed...

You have to be lucky if storing is possible or some GDI or memory error occurs preventing from saving your work

It's really terrible and I do not understand why PTC does not underatke anything to correct the bugs in this software!

When you were trying to provide a screenshot?

Mike

now I took the time to serve you.

handing over 1 to f(x) should return 3!

VladimirN
24-Ruby II
(To:Efried)

And what happens if you open Mathcad example (from Mike) above?

It is clear that everybody has tested trivial examples. I guess in my case the problem might be the trace statement. So my problem looks like this

trace("xy") if VV = true

if ()

statements

otherwise

statements

The whole if otherwise block is skipped!

I have identified the same problem in various programms now! Some sort of worst case scenario if you cannot rely on software integrity!

Efried wrote:

It is clear that everybody has tested trivial examples.

Trivial? We offered solutions as no example was presented in the first place.

Can you not provide a Mathcad worksheet?

Mike

RichardJ
19-Tanzanite
(To:Efried)

It's not a bug. You just misunderstand how a sequence of if statements work. If there are no other lines in the program between if and otherwise statements they are taken as one logical block. This is necessary, to be able to handle multiple possible cases, with a final "otherwise" to catch any cases that are not explicitly handled. Note the difference:

if statements.png

You are not the first person to be confused by this. The way the program is written is rather ambiguous, and relies on the reader to know what this structure will do. It would be preferable if it were obvious to the casual reader. That is exactly why the syntax in Prime was changed. In Prime you have "if", "else if" "also if" and "else" statements, so there is no confusion about what the program will do.

Brilliant explanation Richard.

Mike

VladimirN
24-Ruby II
(To:Efried)

Please provide Mathcad worksheet or screenshot of this issue.

Announcements

Top Tags