This article describes what to do if command-line arguments are supplied to a program with parentheses "()" instead of "=".
Problem:
When executing the following command:
cobrun program file=myfile output=outputfile
when the arguments are retrieved in the COBOL application, the “=” character is removed and the argument is bracketed with “()” parentheses, like this:
file(myfile) output(outputfile)
Resolution:
The replacement of the “=” characer by parentheses occurs because of the parsing of the command by the cobrun command. If the application is built as a standalone executable, this parsing of the command-line arguments does not occur, and the values retrieved by the COBOL program are exactly as entered on the command line. To retrieve arguments without the parentheses, use the command:
Cobrun program file==myfile output==outputfile.
A program to test command-line handling is attached to this document.
Example 1:
The compilation command is:
cob –iav cmdline3.cbl
(compile the program to interpreted code)
Execute the program using:
cobrun cmdline3 file=myfile output=outputfile
The program returns the arguments:
file(myfile) output(outputfile)
Example 2:
The compilation command is:
cob –iav cmdline3.cbl
(compile the program to interpreted code)
Execute the program using:
cobrun cmdline3 file==myfile output==outputfile
The program returns the arguments
file=myfile output=outputfile
Example 3:
The compilation command is:
cob –x cmdline3.cbl
(create a standalone executable)
Execute the program using:
./cmdline3 file=myfile output=outputfile
The program returns the arguments:
file=myfile output=outputfile