Command procedure

From VSI OpenVMS Wiki
Revision as of 06:16, 19 December 2018 by Darya.zelenina (talk | contribs) (Created page with "A '''command procedure''' is a file that holds a sequence of DCL commands to be executed by the system in sequence interactively or as a batch job - essentially a DCL scri...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

A command procedure is a file that holds a sequence of DCL commands to be executed by the system in sequence interactively or as a batch job - essentially a DCL script. Command procedure files have the extension of .COM.

Rules and conventions

Command procedures in OpenVMS follow a set of rules; if they are broken, an error message is displayed and the command procedure may fail.

1. Every line in a command procedure that is not a data line has to begin with the dollar sign ($):

$ if f$mode() .nes. "INTERACTIVE" then exit
 

2. Comments begin with an exclamation point (!). Comment lines begin with a dollar sign AND an exclamation point ($!):

$ if count .eq. 5 !Last element
$! Return to the previous level
 

There are also certain conventions that it is recommended to follow to improve clarity and maintainability of the code:

1. Give your command procedure a name that indicates its purpose and use .COM as the file type.

2. Use complete names for commands and qualifiers. This will help to ensure that your command procedure is upwardly compatible to future releases of OpenVMS.

3. Start each command procedure with one or more comment lines, at least stating the purpose of the command procedure.

4. End the command procedure with an EXIT or STOP statement.

Example

$! This command procedure displays a message based on the current day of the week.
$ say := write sys$output
$ day = f$cvtime(,,"WEEKDAY")
$! show sym day
$ say "Hooray, it's ''day'!"
 

Command procedures used by OpenVMS