Command Processor Quirk?
The other day, while I was creating a new utility command to use with PC Support, I came across a strange quirk of the command processor. I defined a parameter as type *CHAR, 64 characters long, so it would accept a complete PC path, including the file name with its extension.
It turns out, however, that the backslash character () is considered an invalid character, unless you enclose the path in single quotes. This means that I could not type SUBDIRFILENAME.EXT in the parameter, but had to enclose it in single quotes. That's not all, though. The worst part is how the command processor treats an unquoted colon character (:).
First, I wanted to specify A: in the path parameter, so I typed in an A and a colon. I kept getting "Invalid directory" messages from DOS and, since DOS doesn't give much detail in its error messages, I was stumped until I started debugging and threw in a breakpoint. The command processor had removed the colon. Further testing revealed the following:
o If you type a colon at the end of an unquoted string, the command processor removes the colon.
o If you type a colon at the end of a quoted string, the command processor preserves the colon.
o If you prompt for the command and type an unquoted string that has an embedded blank and ends in a colon, the colon is preserved because in this case the command prompter supplies the quotes, turning the string into a quoted string.
If the above steps are repeated using a parameter of type *CMDSTR (command string), the results are different:
o Ending colons are always preserved.
o If you type an embedded colon, the portion of the command string prior to the colon is assumed to be a label (as in a CL program) and the portion after the colon is assumed to be a valid command name. If the command doesn't exist, you get an error message.
o If you embed two or more colons, you get an error message because there's more than one label in the command.
o Backslash characters are invalid in command parameters, in the portion before the first blank (which is assumed to be the command name) and in unquoted command parameters.
I can understand about the backslashes being invalid characters, but why isn't the colon treated the same way? It took me a while to find the source of the problem, and I can find no circumvention. To this day, I have to make sure I enclose in quotes the PC path in my custom PC Support commands. I've included a simple command and its processing program (Figures 1 and 2) for you to try out this quirk.
TechTalk: Command Processor Quirk?
Figure 1 Command #EM002
/* */ /* To compile: */ /* */ /* CRTCMD CMD(XXX/#EM002) PGM(XXX/#EM002CL) + */ /* SRCFILE(XXX/QCMDSRC) */ /* */ #EM002: CMD PROMPT('Test Command') PARM KWD(CHAR) TYPE(*CHAR) LEN(32) + PROMPT('Character') PARM KWD(CMD) TYPE(*CMDSTR) LEN(32) + PROMPT('Command')
TechTalk: Command Processor Quirk?
Figure 2 CL Program #EM002CL
/* */ /* To Compile: */ /* */ /* CRTCLPGM PGM(XXX/#EM002CL) SRCFILE(XXX/QCLSRC) */ /* */ #EM002CL: PGM PARM(&CHAR &CMD) DCL VAR(&CHAR) TYPE(*CHAR) LEN(32) DCL VAR(&CMD) TYPE(*CHAR) LEN(32) SNDPGMMSG MSG('Char =' *BCAT &CHAR) MSGTYPE(*INFO) SNDPGMMSG MSG('Cmd =' *BCAT &CMD) MSGTYPE(*INFO) ENDPGM
LATEST COMMENTS
MC Press Online