Using command-line arguments

You can pass arguments to a main program on the command line. The operating system calls main programs with null-terminated strings that contain the arguments.

If the arguments that are entered are shorter than the COBOL data-names that receive them, use the technique to isolate them that is shown in the related task below about manipulating null-terminated strings.

How the arguments are treated depends on whether you use the -host option of the cob2 command (or one of its variants).

If you do not specify the -host option, command-line arguments are passed in native data format, and AIX calls all main programs with the following arguments:

If you specify the -host option, AIX calls all main programs with an EBCDIC character string that has a halfword prefix that contains the string length. You must enter the command-line arguments as a single string enclosed in quotation marks ("). To pass a quotation-mark character in the string, precede the quotation mark with the backslash (\) escape character.

related references  
cob2, cob2_j, and cob2_r options