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

How to avoid wrong branching?

Highlighted
Newbie

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...

Tags (3)
11 REPLIES 11
Highlighted

Re: How to avoid wrong branching?

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

Clipboard01.jpg

Mike

Highlighted

Re: How to avoid wrong branching?

MikeArmstrong wrote:

...It seems ok to me...

For me too (Mathcad 15 M010).

Highlighted

Re: How to avoid wrong branching?

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!

Highlighted

Re: How to avoid wrong branching?

When you were trying to provide a screenshot?

Mike

Highlighted

Re: How to avoid wrong branching?

now I took the time to serve you.

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

Highlighted

Re: How to avoid wrong branching?

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

Highlighted

Re: How to avoid wrong branching?

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!

Highlighted

Re: How to avoid wrong branching?

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

Highlighted

Re: How to avoid wrong branching?

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.

Highlighted

Re: How to avoid wrong branching?

Brilliant explanation Richard.

Mike

Highlighted

Re: How to avoid wrong branching?

Please provide Mathcad worksheet or screenshot of this issue.

Announcements