1 CALLTransfers control to a labeled subroutine within a command procedure. Format CALL label [parameter [...]] 2 Parameters label Specifies a label of 1 to 255 alphanumeric characters that appears as the first item on a command line. A label cannot contain embedded blanks. When the CALL command is executed, control passes to the command following the specified label. The label can precede or follow the CALL statement in the current command procedure. A label in a command procedure must be terminated with a colon (:). Labels for subroutines must be unique. Labels declared in inner procedure levels are inaccessible from outer levels, as in the following example: $CALL B $SUBROUTINE A $ B: SUBROUTINE $ ENDSUBROUTINE $ENDSUBROUTINE In this example, the label B in subroutine A is inaccessible from the outer procedure level. parameter [...] Specifies from one to eight optional parameters to pass to the command procedure. Use quotation marks ("") to specify a null parameter. The parameters assign character string values to the symbols named P1, P2, and so on in the order of entry, to a maximum of eight. The symbols are local to the specified command procedure. Separate each parameter with one or more spaces. You can specify a parameter with a character string value containing alphanumeric or special characters, with the following restrictions: o The command interpreter converts alphabetic characters to uppercase and uses blanks to delimit each parameter. To pass a parameter that contains embedded blanks or lowercase letters, enclose the parameter in quotation marks (" "). o If the first parameter begins with a slash (/), you must enclose the parameter in quotation marks. o To pass a parameter that contains quotation marks and spaces, enclose the entire string in quotation marks and use two sets of quotation marks within the string. For example: $ CALL SUB1 "Never say ""quit""" When control transfers to SUB1, the parameter P1 is equated to the following string: Never say "quit" If a string contains quotation marks and does not contain spaces, the quotation marks are preserved in the string and the letters within the quotation marks remain in lowercase. For example: $ CALL SUB2 abc"def"ghi When control transfers to SUB2, the parameter P1 is equated to the string: ABCdefGHI To use a symbol as a parameter, enclose the symbol in single quotation marks (' ') to force symbol substitution. For example: $ NAME = "JOHNSON" $ CALL INFO 'NAME' The single quotation marks cause the value "JOHNSON" to be substituted for the symbol 'NAME'. Therefore, the parameter "JOHNSON" is passed as P1 to the subroutine INFO. 2 Qualifier /OUTPUT /OUTPUT=filespec Writes all output to the file or device specified. By default, the output is written to the current SYS$OUTPUT device and the output file type is LIS. System responses and error messages are written to SYS$COMMAND as well as to the specified file. If you specify /OUTPUT, the qualifier must immediately follow the CALL command. The asterisk (*) and the percent sign (%) wildcard characters are not allowed in the output file specification. You can also redefine SYS$OUTPUT to redirect the output from a command procedure. If you place the following command as the first line in a command procedure, output will be directed to the file you specify: $ DEFINE SYS$OUTPUT filespec When the procedure exits, SYS$OUTPUT is restored to its original equivalence string. This produces the same result as using the /OUTPUT qualifier when you execute the command procedure. 2 Example $ $! CALL.COM $ $! Define subroutine SUB1 $! $ SUB1: SUBROUTINE . . . $ CALL SUB2 !Invoke SUB2 from within SUB1 . . . $ @FILE !Invoke another procedure command file . . . $ EXIT $ ENDSUBROUTINE !End of SUB1 definition $! $! Define subroutine SUB2 $! $ SUB2: SUBROUTINE . . . $ EXIT $ ENDSUBROUTINE !End of SUB2 definition $! $! Start of main routine. At this point, both SUB1 and SUB2 $! have been defined but none of the previous commands have $! been executed. $! $ START: $ CALL/OUTPUT=NAMES.LOG SUB1 "THIS IS P1" . . . $ CALL SUB2 "THIS IS P1" "THIS IS P2" . . . $ EXIT !Exit this command procedure file The command procedure in this example shows how to use the CALL command to transfer control to labeled subroutines. The example also shows that you can call a subroutine or another command file from within a subroutine. The CALL command invokes the subroutine SUB1, directing output to the file NAMES.LOG and allowing other users write (W) access to the file. The subroutine SUB2 is called from within SUB1. The procedure executes SUB2 and then uses the @ (execute procedure) command to invoke the command procedure FILE.COM. When all the commands in SUB1 have executed, the CALL command in the main procedure calls SUB2 a second time. The procedure continues until SUB2 has executed.