There's a lot more on error handling. above possibilities are a brute_exit I would not suggest - nor allow them on my system! It won't tell me ANYTHING on what went wrong.
Ok.
ANY executed image will return a value. DCL will store this in a local variable $STATUS.
Part of this value - actually, the 3 least significant bits - hold the severity, aslo stored in local symbol $SEVERITY. above statements are a shortcut, where $SEVERITY is checked.
As each image, and for a part, DCL commands will delever a condition value, $STATUS - and because of that, $SEVERITY - will be overwritten. You should save it's value before doing anything else with it.
FYI:
These are the valid severities within VMS.
first column: LSB, last 3 bits explicit
Second column: possible HEX values
Third column: severity
xxxxxxx000 0, 8 WARNING (-W-)
xxxxxxx001 1, 9 SUCCESS (-S-)
xxxxxxx010 2, A ERROR (-E-)
xxxxxxx011 3, B INFORMATIONAL (-I-)
xxxxxxx100 4, C FATAL (-F-)
rset to be consideerd "reserved" - not used
aqs you can see: Anything that signals seomething (possibly) wrong is EVEN. Anything where nothing is wrong, is ODD.
In programs, it is a normal practice to check for ODD or EVEN. The first marks a succesfull completion, the latter marks something has gone wrong in some way.
It's a good practice to signal 'the VMS way'. DCL lexical F$MESSAGE will format the value and return the facility and text automatically:
$ DoSomething
$ S = f$integer($STATUS)
$ if (S/2)*2 .eq. S
$ then
$ write sys$output "Something wrong, ''f$message(S))'"
$ goto end_job
$ endif
Or, if you want to use ON ERROR
$ ON ERROR THEN GOTO ERRLBL
$ DoSomething
$! here, either S, I or W!
....
$ GOTO END_JOB
$!
$ERRLBL:
$ write sys$output "Something wrong, ''f$message(S))'"
$ goto end_job
$ENDJOB:
$ EXIT
Last thing: Try to prevent a direct reference to a value. In most cases, $SEVERITY is enough to distinguish between 'good' and 'bad' and take appropaite action. A lot of DCL commands have options that imply error handling (most appearant in file access. OPEN, READ and WRITE all have an /ERROR=<label> option, READ has 'END_OF_FILE=<label> as well). Use them. It's the clearest way of DCL programming!
Willem
Willem Grooters