IBM Support

Cobol AIX reading command line arguments.

Troubleshooting


Problem

Programmer was unable to receive a variable length parameter into a COBOL program. Program was invoked from the command line and the program needed to accept a parameter of variable length that was passed in from the command line. Program moved the first parameter into a variable defined as 05 LS-DATABASE PICTURE X(10) VALUE SPACE. When the first parm out of 3 parms that were passed in was only 5 characters in length the other parms passed in were moved into the variable causing errors when referencing the variable.

Environment

AIX

Resolving The Problem

UNSTRING LS-DATABASE DELIMITED BY X'00' INTO WS-DATABASE.
The first parm will be parsed and assigned to a variable in working-storage. This allows arguments of various lengths to be passed into the program via the command line. The UNSTRING statement is documented in the COBOL Language Reference. However, it depends if you use the -host option or not. For a full example of both ways, see chapter 27, page 496 of the COBOL for AIX Programming Guide SC23-8566-00. The same examples are also in the older Programming Guide chapter 26 page 430 SC18-9256-00.

Related Information

[{"Product":{"code":"SS6SGM","label":"COBOL for AIX"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"Compiler","Platform":[{"code":"PF002","label":"AIX"}],"Version":"2.0;3.1","Edition":"","Line of Business":{"code":"LOB17","label":"Mainframe TPS"}}]

Document Information

Modified date:
08 August 2018

UID

swg21175692