Difference between revisions of "Command procedure"

From VSI OpenVMS Wiki
Jump to: navigation, search
(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...")
 
(Merge info from Command Procedure, tidy enumeration)
 
Line 1: Line 1:
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 [[File extension|extension]] of .COM.
+
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 [[File extension|extension]] of .COM.
  
 
=Rules and conventions=
 
=Rules and conventions=
Line 15: Line 15:
 
There are also certain conventions that it is recommended to follow to improve clarity and maintainability of the code:
 
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.
+
# 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.
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.
+
# Start each command procedure with one or more [[Comment|comment]] lines, at least stating the purpose of the command procedure.
 
+
# End the command procedure with an EXIT or STOP statement.
3. Start each command procedure with one or more [[Comment|comment]] lines, at least stating the purpose of the command procedure.
 
 
 
4. End the command procedure with an EXIT or STOP statement.
 
  
 
=Example=
 
=Example=

Latest revision as of 12:59, 23 March 2022

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:

  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