Proper DCL (under construction)

This document describes a coding style for DCL procedures which ensures that procedures are

Layout of a DCL procedure

A procedure should consist of 3 sections As an example is shown an excerpt of the procedure disk_getquota.com: $ wo := write sys$output ! SETUP $ pid = f$getjpi("","PID") ! SETUP . . more setup code . $! $ exit_status = 1 ! BODY $ on severe then goto finish_error ! BODY $ on control_y then goto finish_ctrly ! BODY $! $ if (disk .eqs. "") then goto bad_para ! BODY . . some action, e.g. to create a file with . the name disk_getquota_'pid'.tmp . $ open/read disk_getquota_lfile disk_getquota_'pid'.tmp . . action to process file "disk_getquota_lfile" . $ close disk_getquota_lfile $! . . more action . $! $ finish: ! FINISH $ close/nolog disk_getquota_lfile ! FINISH $ if (f$search("disk_getquota_''pid'.tmp") .nes. "") then - delete disk_getquota_'pid'.tmp;* ! FINISH $ exit exit_status ! FINISH $! $ finish_error: ! FINISH $ exit_status = $status ! FINISH $ goto finish ! FINISH $ finish_ctrly: ! FINISH $ exit_status = %x10000004 ! FINISH $ goto finish ! FINISH $! $ bad_para: ! FINISH $ wo "%DISK_GETQUOTA-E Specify disk and owner" ! FINISH $ exit_status = %x10000002 ! FINISH $ goto finish ! FINISH The setup section contains code to define all symbols needed in the finish section, e.g. pid and wo are defined here because they are used during cleanup. The setup section should NOT contain any statements which could potentially fail or any statements which allocate resources.

The body starts with a DCL ON SEVERE and ON CONTROL_Y statements which setup an action, a branch to the labels finish_error and finish_ctrly, for all exceptions. The body should never use an exit statement, all error exits should be done with a goto finish.

The finish section takes care of cleaning up and returning with the proper exit status.

Back to KP3 Computing home page


Last updated: May 19th, 1994
Walter F.J. Müller

Imprint ---- Data privacy protection ---- Haftungsausschluss