Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X
Hi All,
I'm a newbie with Mathcad and I'm self taught so I hope this is an easy on for you guys!!
I'm trying to get my head round why this formula doesn't work so any help would be great.
See the attached Mathcad 15 file.
I'm using if statements to pick the correct answer but I can't get it to completely work. At one point I thought I had it but then when you test it there's always one way it fails. grrrrrrrrrrr
Best Regards
Jonno
Solved! Go to Solution.
Andy has already stated the problem with your (and Alans) routine.
The expression
will always simplify to TRUE and so despite the returns also Alans approach would yield AllowYield everytime, disregarding the value of Yield.
Here is an alternative approach which I guess does what you had in mind.
You might consider turning the routine into a function to be more versatile.
Use the return statement to force the program to exit. Without that, as you note, it will always drop through to he next line.
alternate suggestion.
1. the Boolean operators take 2 logical inputs so where you write IF yield = 60 OR 75, Mathcad checks if yield =60 is true; or if 75 is true. any non zero number is true so therefore 75 = true
This needs to be written IF yield=60 OR yield =75
2 you need to consider the logic of the next statement : IF yield NOT= 60 OR yield NOT=75
one of the statements must be true so this will always be true.
it needs to change to: IF yield NOT= 60 AND yield NOT=75.
Hope this helps
Andy
This needs to be written IF yield=60 OR yield =75
Oops! Good catch. I missed that
Thanks for answering my question Richard!!!
Thanks for your reply! This works so i would of given it a correct answer but it wont let me put two correct answers down
Andy has already stated the problem with your (and Alans) routine.
The expression
will always simplify to TRUE and so despite the returns also Alans approach would yield AllowYield everytime, disregarding the value of Yield.
Here is an alternative approach which I guess does what you had in mind.
You might consider turning the routine into a function to be more versatile.
Thanks Leopold!!
This works great and you have shortened my formula!!!