HP Forums
Error catching - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Error catching (/thread-3182.html)

Error catching - salvomic - 02-23-2015 02:25 PM

I need some help to use error catching, programming for the Prime.
We have IFERR; please, suggest a few example of use for the above purpose...
Then we have also IF TYPE(var) = 5 \\ error ...

My principal goal is to catch errors with parameters or arguments incorrectly entered by the user; i.e. if we have a command myCommand(a, b, c), I want to catch the error if an argument is missing or for error "Bad argument value", to make that program doesn't exit, but give error handled (i.e. a MSGBOX or print() with a string).
An argument can have a default value (a=0) or not, if not and the user don't give it I want to advise him with a meaningful string, instead of the rough, generic, error.

Any hints?

for now, in CAS I'm using something like

local argv,argc,...;
a := argv(1);
b := argv(argc);
IF argc=3 THEN ...

but in Home, after many tries, I saw that I must use
argc:= CAS.size(argv);
and I'm not able to use argv:= [args], as it gives error, so I try to use only args directly...