Get Help

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- How to avoid wrong branching?

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Showing results for

02-10-2012
04:33 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-10-2012
04:33 AM

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

02-10-2012
04:42 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-10-2012
04:42 AM

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

Mike

02-10-2012
06:15 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-10-2012
06:15 AM

MikeArmstrong wrote:

...It seems ok to me...

For me too (Mathcad 15 M010).

02-10-2012
04:58 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-10-2012
04:58 AM

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!

02-10-2012
06:14 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-10-2012
06:14 AM

When you were trying to provide a screenshot?

Mike

02-10-2012
09:30 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-10-2012
09:30 AM

now I took the time to serve you.

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

02-10-2012
06:17 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-10-2012
06:17 AM

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

02-10-2012
06:57 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-10-2012
06:57 AM

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!

02-10-2012
07:41 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-10-2012
07:41 AM

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

02-10-2012
11:49 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-10-2012
11:49 AM

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:

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.

02-11-2012
02:24 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-11-2012
02:24 AM

Brilliant explanation Richard.

Mike

02-10-2012
06:12 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-10-2012
06:12 AM

Please provide Mathcad worksheet or screenshot of this issue.