Computing.Net > Forums > OpenVMS > errorhandling in VMS files

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

errorhandling in VMS files

Reply to Message Icon

Name: shree
Date: June 4, 2004 at 05:13:59 Pacific
OS: OVMS
CPU/Ram: 512
Comment:

hello friend,
can u tell me the way to have error handling of files with OVMS



Sponsored Link
Ads by Google

Response Number 1
Name: shahnawaz
Date: June 4, 2004 at 13:22:07 Pacific
Reply:

try the following global commands


$ on warning then goto end_of_job
$ on error then goto end_of_job
$ on control_y then goto end_of_job



0

Response Number 2
Name: WillemGrooters
Date: June 9, 2004 at 07:07:38 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to OpenVMS Forum Home


Sponsored links

Ads by Google


Results for: errorhandling in VMS files

Any 'For Loop' equilavent in VMS? www.computing.net/answers/openvms/any-for-loop-equilavent-in-vms/409.html

How to Search a Keyword in a File www.computing.net/answers/openvms/how-to-search-a-keyword-in-a-file/441.html

changing chars in a file from DCL www.computing.net/answers/openvms/changing-chars-in-a-file-from-dcl/529.html