The rules for forming a command from an expression are exactly the same as those for forming expressions. Be careful of symbols that have meanings for both REXX and OS/2 programs. The DIRREX.CMD program below shows how REXX evaluates a command when the command name and a variable name are the same:
/* DIRREX.CMD -- assign a value to the symbol DIR */ say "DIR command using REXX" dir = "echo This is not a directory." /* pass the evaluated variable to OS/2 */ dir
Because Dir is a variable that contains a string, the string is passed to OS/2. The OS/2 DIR command is not executed. Here are the results:
[C:\]dirrex DIR command using REXX: This is not a directory. [C:\]
REXX evaluates a literal string--a string enclosed in matching quotation marks--exactly as it is. To ensure that a symbol in a command is not evaluated as a variable, enclose it in matching quotation marks as follows:
/* assign a value to the symbol DIR */ say "DIR command using REXX" dir = "echo This is another string now." /* pass the literal string "dir" to OS/2 */ "dir"
REXX displays a directory listing.
The best way to ensure that REXX passes a string to the OS/2 as a command is to enclose the entire clause in quotation marks. This is especially important when you use symbols that REXX uses as operators.
If you want to use a variable in the command string, leave the variable outside the quotation marks. For example:
extension = "BAK" "delete *."▌▌extension option = "/w" "dir"▌▌option