Command procedure
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 by convention 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:
- Give your command procedure a name that indicates its purpose and use .COM as the file type.
- Use complete names for commands and qualifiers. This will help to ensure that your command procedure is upwardly compatible to future releases of OpenVMS.
- Start each command procedure with one or more comment lines, at least stating the purpose of the command procedure.
- 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'!"