I built a simple program try to print the command line parameters.
The code is below and I built an executable file (TEST.EXE).
int main(int argc, char *argv[])
{
int i;
printf("%s\n",argv[0]);
for (i = 1; i < argc; i++)
printf("argument %d: %s\n", i, argv[i]);
exit (EXIT_SUCCESS);
}
I try to run the TEST.EXE and print the parameters but fail.
The result of command RUN TEST.EXE test1 test2
:
%DCL-W-MAXPARM, too many parameters - reenter command with fewer parameters
What can I do to print "test1" and "test2"?
In addition, if you need to preserve the case of the arguments, you have to quote these arguments or enter
once in the lifetime of your process and
before running your program with a specific foreign command or by using automatic foreign commands (DCL$PATH). Otherwise all the unquoted arguments are converted to lowercase characters.
PS: VMS has a command language, that is, you have to enter a command to run a program. By default, file names are no commands. With defining DCL$PATH you change this default behaviour.
The
RUN
command doesn't support any command line arguments. Define a foreign command and use that instead. From David Mathog's beginner FAQ:Defining a foreign command as per 'a3f' is the 'proper' way to do it albeit somewhat tedious and 2-stepped.
You may also want to try the MCR 'trick'. MCR being short for the Monitor Command Routine from the 40+ year old PDPD-11 Operating System RSX.
Now MCR defaults to look for program in SYS$SYSTEM, so you do have to specify the current location:
There is also a 1-1/2 step approach using DCL$PATH. This works mostly like the Unix and Windows path, providing places to look for DCL scripts or programs if an unknown command is entered.
For example
Now just type :
TEST this.
Hein