Symbol substitution during this phase is not iterative.
During the expression evaluation phase:
Symbol substitution during this phase is not iterative.
Note that the command interpreter does not scan any lines that are read as input data by commands or programs executed within a command procedure. Therefore, the command interpreter does not perform symbol substitution within these data lines.
In the following example, the program AVERAGE reads 55, 57, and 9999 from SYS$INPUT (the command input stream). These data lines are never read by the command interpreter. If you enter symbol names as input, they are not evaluated:
$ RUN AVERAGE 55 57 9999
Symbol substitution can be repetitive or iterative:
When you use an apostrophe (') to request symbol substitution, the command interpreter performs iterative substitution during the first phase of command processing.
Substitution using apostrophes is not iterative when a symbol is included in a quoted character string.
In the following example, the substitution is not iterative:
$ MAC = "5" $ A = "''MAC'" $ B = "''A'" $ SHOW SYMBOL B B = 5 Hex = 00000005 Octal = 00000000005
After the statement B = 'A' the resulting value of the symbol B is 5 because:
Note, however, what happens when you include A in a quoted character string:
$ B = "''A'" $ SHOW SYMBOL B B = "'MAC'"
In this case, B has the value 'MAC'. The symbol name A is replaced only once because substitution is not iterative within quoted character strings.
The command interpreter performs iterative substitution automatically only when an apostrophe is in the command line. In some cases, you may want to nest command synonym definitions.
In the following example, when EXEC is processed, the command interpreter performs substitution only once:
$ MAC = "TYPE A.B" $ EXEC = "'MAC'" $ EXEC
The result is the string 'MAC'. The command interpreter displays an error message because it does not recognize MAC as a command. This error occurs because during the first phase of command processing, no substitution is performed (the string EXEC is not delimited by apostrophes). During the second phase, the string 'MAC' is substituted for EXEC because EXEC is the first value on the command line. This substitution is not iterative. Therefore, even though 'MAC' is delimited by apostrophes, no additional substitution is performed.
To use the command synonym EXEC correctly, enclose it in apostrophes:
$ 'EXEC'
In this case, the symbol EXEC is evaluated during the first phase of command processing. Because this substitution is iterative, ('MAC') is also evaluated and the string TYPE A.B is substituted.
When the command interpreter analyzes an expression in a command, any symbols specified in the expression are replaced only once. You can, however, force iterative substitution by using an apostrophe or an ampersand in the expression. When you force iteration in this way, you must remember the following:
Note, however, that if substitution does not result in a valid symbol name, the command fails.
$ P1 = "FRED.DAT" $ COUNT = 1 $ IF P'COUNT' .EQS. "" THEN GOTO END
IF P1 .EQS. "" THEN GOTO END
$ FILENAME = "A.B" $ IF 'FILENAME' .NES. "" THEN TYPE 'FILENAME'
IF A.B .NES. "" THEN TYPE A.B
$ IF FILENAME .NES. "" THEN TYPE 'FILENAME'
If a symbol is not defined when it is used in a command line, the command interpreter either displays an error message or replaces the symbol with a null string, depending on the context. The rules are as follows:
$ FILE := MYFILE'FILE_TYPE' $ SHOW SYMBOL FILE FILE = "MYFILE" $ PRINT 'FILE'
$ A = 1 $ C = A + B %DCL-W-UNDSYM, undefined symbol - check validity and spelling
You can also invoke a command procedure (.COM file type) or executable image (.EXE file type) from DCL level without defining a symbol for that procedure. Using automatic foreign commands, DCL can search a specific set of directories for a command procedure or executable image and run it automatically.
When you enter a command verb that is not a DCL symbol and that is not in the DCL command tables, the system usually displays the following message:
DCL-W-IVVERB, unrecognized command verb - check validity and spelling
However, if the logical name DCL$PATH is defined (and is not blank), DCL instead performs an RMS $SEARCH for any file that contains the invalid verb in its file name and DCL$PATH:.* as the default file specification.
If DCL finds a .COM or .EXE file, DCL will automatically execute that file with the rest of the command line as its parameters. (This behavior is similar to the PATH options found in DOS, UNIX, and other operating systems.)
In the following example, the DCL symbol SYSGEN is no longer needed. DCL looks in the SYS$SYSTEM directory and finds SYSGEN.EXE. DCL acts like the symbol "SYSGEN" was defined as "$SYS$SYSTEM:SYSGEN" which causes the SYSGEN image to be activated as a foreign command.
$ SYSGEN %DCL-W-IVVERB, unrecognized command verb - check validity and spelling \SYSGEN\ $ DEFINE DCL$PATH SYS$SYSTEM,SYS$DISK:[]FOO $ SYSGEN SHOW MAXPROCESSCNT Parameter Name Current Default Min. Max. Unit Dynamic -------------- ------- ------- ------- ------- ---- ------- MAXPROCESSCNT 157 32 12 8192 Processes
In the following example, SS does not need to the defined as "@SS.COM" because DCL will automatically search the SYS$SYSTEM directory for SS.COM or SS.EXE. If that fails, DCL will search the current directory for SS.COM or SS.EXE.
$ TYPE SS.COM $ SHOW SYMBOL/LOCAL/ALL $ EXIT $ SS "This is a parameter" P1 = "This is a parameter" P2 = "" P3 = "" P4 = "" P5 = "" P6 = "" P7 = "" P8 = "" $ SS.EXE "This is a parameter" P1 = ".EXE" P2 = "This is a parameter" P3 = "" P4 = "" P5 = "" P6 = "" P7 = "" P8 = ""
In the example, DCL locates SS.COM and acts like "SS" had been a symbol defined as "@SS.COM". The command procedure is activated with the rest of the command line parsed as parameters. Note that "SS.EXE" does not invoke the image SS.EXE, but instead invokes SS.COM with two parameters, the first being the text string ".EXE". This is consistent with the way command parsing and symbol substitution is performed by the OpenVMS operating system.
Note the following:
If you are a privileged user and set your default device and directory to other user accounts, you should not place "SYS$DISK:[]" in the definition of the DCL$PATH logical name. Doing so will cause DCL to search the current directory, where a typographical error or poor placement of the translation within the search list could cause user images in the current directory to be found and mistakenly invoked with privileges.
Note the following restrictions:
$ DEFINE DCL$PATH SYS$SYSTEM,SYS$DISK:[]FOO $ TYPE SHOWME.COM $ SHOW SYMBOL P1 $ EXIT $ SHOWME USERS OpenVMS User Processes at MARCH 2, 1996 01:40 PM Total number of users = 1, number of processes = 11 Username Interactive Subprocess Batch RSMITH 9 2
Command procedures are files that contain DCL commands and data lines used by DCL commands. This chapter is divided into major sections that include the following:
Refer to the OpenVMS DCL Dictionary for complete information on all commands described in this chapter.
There are two types of DCL command procedures:
There are two ways to create command procedures:
The file that you create can contain command lines, labels, comments, conditional statements, and variables.
The default file type for command procedures is .COM. If you specify the .COM file type when you name a command procedure, you can execute the procedure by specifying the file name only. The SUBMIT and execute procedure (@) commands assume the file type is .COM unless you specify otherwise.
The following are suggestions for including commands in command procedures:
$ PRINT LAB.DAT - /AFTER=17:00 - /COPIES=20 - /NAME="COMGUIDE"
When writing command lines:
$ ! Everything between the commands DECK and EOD $ ! is written to the file WEATHER.COM $ ! $ CREATE WEATHER.COM $ DECK $ FORTRAN SUMMER $ LINK SUMMER $ RUN SUMMER $ EOD $ ! $ ! Now execute WEATHER.COM $ @WEATHER $ EXIT
Note that command lines that do not begin with a dollar sign might be correctly interpreted by DCL, but Digital strongly recommends that any DCL command line start with a dollar sign.
The following sections describe how to use labels.
Labels are used in DCL command procedures to mark the beginning of loops, sections of code, or subroutines. Note the following rules when using labels:
As the command interpreter encounters labels, it enters them in a special section of the local symbol table. The amount of space available for labels is limited. If a command procedure uses many symbols and contains many labels, the command interpreter might run out of symbol table space and issue an error message. If this occurs, include the DELETE/SYMBOL command in your procedure to delete symbols as they are no longer needed. (Note, however, that you cannot delete labels.)
If a command procedure uses the same label more than once, the new definition replaces the existing one in the local symbol table.
When duplicate labels exist, the GOTO command transfers control to the label that DCL has processed most recently. The GOTO command also uses the following rules when processing duplicate labels:
The following sections describe how to use comments in command procedures.
It is good programming practice to include comments in command procedures. Comments can be helpful when updating or troubleshooting the command procedure. Comments can be used as follows:
The following rules apply when writing comments in command procedures:
Before you begin writing a command procedure, perform the tasks interactively that the command procedure will execute. As you type the necessary commands, note any variables and conditionals that are used, and any iterations that occur.
The following sections contain the steps to write a simple command procedure. The example used throughout these sections is a command procedure called CLEANUP.COM. This procedure can be used to clean up a directory.
Follow these steps to write a command procedure:
Step | Task |
---|---|
1 | Design the command procedure. |
2 | Assign variables and test conditionals. |
3 | Add loops. |
4 | End the command procedure. |
5 | Test and debug the program logic. |
6 | Add clean up tasks. |
7 | Finish the procedure. |
Follow these steps to design a command procedure:
Step | Task |
---|---|
1 | Decide which tasks your procedure will perform. |
2 | Determine any variables your command procedure will use and how they will be loaded. |
3 | Determine what conditionals the command procedure requires and how you will test them. |
4 | Decide how you will exit from the command procedure. |
There are certain commands that are usually executed during clean up operations. The following table lists those commands and the tasks that they perform:
Command | Task Performed |
---|---|
DIRECTORY | Displays the contents of the current directory |
TYPE filespec | Displays a file |
PURGE filespec | Purges a file |
DELETE filespec | Deletes a file |
COPY filespec new-filespec | Copies a file |
Any data that changes when you perform a task is a variable. If you create or delete files in your directory, the file names will be different each time you clean your directory; therefore, the file names in CLEANUP.COM are variables.
Any command that must be tested each time you execute a command procedure is considered conditional. Because any or all of the commands in CLEANUP.COM might be executed, depending on the operation you need to perform, each command is conditional.
After you have determined what variables and conditionals you will use in the CLEANUP.COM command procedure, you must decide how to load the variables, test the conditionals and exit from the command procedure. For the CLEANUP.COM command procedure, the following decisions have been made:
Task | How Accomplished |
---|---|
Load variables | The command procedure gets the file names from the terminal. |
Test Conditionals |
The command procedure:
|
Exit from loop | You must enter the EXIT command to exit from the loop. |
To make command procedures easier to understand and maintain, write statements so the procedures execute from the first command to the last command.
There are many ways to assign values to variables. In this section, we will discuss using the INQUIRE command. For additional methods, see Chapter 16.
Follow these steps to assign values to variables and test conditionals:
Step | Task |
---|---|
1 | Assign values to variables using the INQUIRE command. |
2 | Determine which action should be taken. |
3 | Test the conditional using IF and THEN statements. |
4 | Write program stubs and insert them into the command procedure as placeholders for commands. |
5 | Write error messages, if necessary. |
The INQUIRE command prompts for a value, reads the value from the terminal, and assigns the value to a symbol.
6489P026.HTM OSSG Documentation 22-NOV-1996 13:17:15.19
Copyright © Digital Equipment Corporation 1996. All Rights Reserved.