Problem:
A COBOL program developed in Net Express 4.0, when run from a command line, is required to read data from a file specified on the command line.
How are parameters read from the command line and redirected to an output file?
Resolution:
1. To read from a file using the redirection operator "<", there is a COBOL runtime switch 'S5' that, when turned on, allows for input/output from the command line. The ACCEPT statement in the code would be:
ACCEPT ... FROM CONSOLE.
To turn the 'S5' COBOL switch on, either set the 'cobsw' environment variable on the command line:
set cobsw= S5
or turn the S5 switch on, when running the program on the command line:
Program1.exe ( S5) < data\\DataIn.dat > data\\DataOut.dat
2. The "ACCEPT ... FROM COMMAND-LINE" statement accepts arguments as strings from the command line. The following will accept '1234' as an argument and redirect the output to an output file:
Program1.exe 1234 1>data\\DataOut.dat
