The Question is:
How can I preserve the (upper- and lower-)case of commandline arguments to a
program invoked from the commandline in a DECterm.
I've had no luck with different combinations of /lower,/nolower,/upper,/noupper
of $ set term.
I would like
$ mcr prog test
$ mcr prog TEST
where the program simply prints argv.
Only if I enclose the argument in double quotation marks is case preserved. Is
that the only way?
LIB$_GETFOREIGN() converts to uppers case unless the argument is enclosed in
double quotation marks. But that leaves the program with the trouble of having
to figure out whether the quotation marks are for case preservation or are
part of the argument.
Thank you very much.
The Answer is :
Please contact Compaq for information on available training programs
and for consulting assistance, and for ordering information and the
availability of OpenVMS documentation.
If you are developing commercial software products for OpenVMS, please
avail yourself of the Compaq Solutions Alliance (CSA) program.
The MCR command is not particularly documented and is not particularly
Use of lib$get_foreign, the DCL$PATH automatic foreign command
mechanism, or traditional foreign commands will be assumed. Use of
undocumented or unusual command syntax (eg: MCR) will be specifically
assumed to be absent. Use of the standard parsing rules will be
assumed; no explicit specification of the new SET PROCESS/PARSE_STYLE
mechanism will be assumed. Further, use of a recent Compaq C compiler
will also be assumed.
Historically, DCL will upcase command input. Historically, the C RTL
will then downcase command input.
Quoting from the Compaq C User's Guide manual section on argc and argv,
with the last paragraph of this quoted text being of particular interest
in this particular case:
"To pass arguments to the main function, you must install the program as
a DCL foreign command. When a program is installed and run as a foreign
command, the argc parameter is always greater than or equal to 1, and
argvalways contains the name of the image file.
The procedure for installing a foreign command involves using a DCL
assignment statement to assign the name of the image file to a symbol
that is later used to invoke the image. For example:
$ ECHO == "$DSK$:COMMARG.EXE"[Return]
The symbol ECHO is installed as a foreign command that invokes the image
in COMMARG.EXE. The definition of ECHO must begin with a dollar sign ($)
and include a device name, as shown.
For more information about the procedure for installing a foreign command,
see the OpenVMS DCL Dictionary.
Example 1-1 shows a program called COMMARG.C, which displays the command-line
arguments that were used to invoke it.
/* This program echoes the command-line arguments. */
int main(int argc, char *argv)
/* argv is program name */
for (i = 1; i < argc; i++)
printf("argument %d: %s\n", i, argv[i]);
You can compile and link the program using the following DCL command lines:
$ CC COMMARG[Return]
$ LINK COMMARG[Return]
A sample output for Example 1-1 follows:
$ ECHO Long "Day's" "Journey into Night"[Return]
argument 1: long
argument 2: Day's
argument 3: Journey into Night
DCL converts most arguments on the command line to uppercase letters.
Compaq C internally parses and modifies the altered command line to make
Compaq C argument access compatible with C programs developed on other
systems. All alphabetic arguments in the command line are delimited by
spaces or tabs. Arguments with embedded spaces or tabs must be enclosed
in quotation marks (" "). Uppercase characters in arguments are converted
to lowercase, but arguments within quotation marks are left unchanged.
That said, beginning with OpenVMS Alpha V7.3, if process parse style is
set to EXTENDED and if the logical name DECC$ARGV_PARSE_STYLE is defined
with the value of ENABLE, the C Run-Time Library will preserve case of
the argv arguments. (This feature may/will appear in ECO kits containing
updates to the Compaq C RTL for OpenVMS OpenVMS Alpha V7.2 and V7.2-1.
This capability will not appear on OpenVMS Alpha versions prior to V7.2.)
The following is an example:
Compaq C V6.4-008 on OpenVMS Alpha V7.3
$ type x.c
main(int argc, char *argv)
$ x = "$sys$disk:x.exe"
$ x A b C d
$ set process/parse=extended
$ x A b C d
$ define DECC$ARGV_PARSE_STYLE enable
$ x A b C d