Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X
Is there anything within Mathcad similar to an IsUndefined function? I'm trying to include some built-in checks for a template I'm working on.
Section "A" of the template has a check "A" (true or false). If check "A" fails, the user needs to continue on to section "B" of the template where exists a check "B". At the end of the document, I want to include something such as CheckAB := CheckA OR CheckB. Since a variable is undefined in section "B" of the document, CheckB has an undefined error, so my final CheckAB function returns an undefined error. I'd like for it to ignore the undefined variable in CheckB and just return the value of CheckA.
Something like this:
CheckAB: if(IsUndefined(CheckB),CheckA,CheckA OR CheckB)
Similarly, it could be written as:
CheckAB := CheckA OR if(IsUndefined(CheckB),False,CheckB)
IsUndefined(x) would return true if x is undefined, and false if x is defined.
Edit: I should clarify that this template will be used by persons running v13-v15.
Solved! Go to Solution.
Sounds like what you're looking for is "on error"
B := NaN on error 5/x
will return B. B will either be 5/x or NaN if there is any error evaluating 5/x.
This can be built to whatever level of complexity you can imagine.
Thanks for the input. Unless I'm missing something, though, I don't think "on error" traps the undefined error. To use your example, if x is undefined, B will not return NaN, it will show an undefined error.
What a coincidence - it appears the second most recent Mathcad post is in regard to this very same issue. I originally did a search in the forum for an answer, but didn't see anything that related to my question. I just checked the Mathcad forum homepage and saw this post:
http://communities.ptc.com/message/192609#192609
Thanks to Richard Jackson for his answer on that post. I made a slight modification to your IsDefined custom function to make it similar to the nz function in Microsoft Access. If you see this post, please reply and I'll credit you with the answer.
Well, I'm glad it was useful to you