You can pass data to a called ILE C program or procedure by using CALL...BY REFERENCE, CALL...BY VALUE, or CALL...BY CONTENT. Refer to Passing Data Using CALL...BY REFERENCE, BY VALUE, or BY CONTENT for a description of how to use CALL...BY REFERENCE, CALL...BY VALUE or CALL...BY CONTENT.
When data is passed to the ILE C program using CALL...BY REFERENCE, a pointer to the data item is placed into the argument list that is accepted by the ILE C program.
When data is passed to the ILE C program using CALL...BY CONTENT, the value of the data item is copied to a temporary location and then a pointer containing the address of the copy's temporary location is placed into the argument list that is accepted by the ILE C program.
For CALL...BY VALUE, the value of the item is placed into the argument list that is accepted by the ILE C program. CALL...BY VALUE can be used to call ILE C procedures but not ILE C program objects.
In your ILE COBOL program, you describe the arguments that you want to pass to the ILE C program or procedure, in the Data Division in the same manner as you describe other data items in the Data Division. Refer to Passing and Sharing Data Between Programs for a description of how to describe the arguments that you want to pass.
When the called ILE C program object begins running, the function main is automatically called. Every ILE C program object must have one function named main. When you pass parameters to the ILE C program object, you must declare two parameters with the function main. Although any name can be given to these parameters, they are usually referred to as argc and argv. The first parameter, argc (argument count), has type int and indicates how may arguments were supplied on the CALL statement that called the ILE C program object. The second parameter, argv (argument vector), has type array of pointers to char array objects.
The value of argc indicates the number of pointers in the array argv. If a program name is available, the first element in argv points to a character array that contains the program name of the invocation name of the ILE C program that is being run. The remaining elements in argv contain pointers to the parameters being passed to the called ILE C program. The last element, argv[argc], always contains NULL.
Refer to the ILE C for AS/400 Programmer's Guide for further information on describing parameters in the called ILE C program or procedure.
ILE C and ILE COBOL have different data types. When you want to pass data between programs written in ILE C and ILE COBOL, you must be aware of these differences. Some data types in ILE C and ILE COBOL have no direct equivalent in the other language.
An ILE C program always expects character strings to terminate with a null character; you should make sure that the string data passed to the ILE C program is null-terminated. Refer to Manipulating null-terminated strings for further information.
Table 18 shows the ILE COBOL data type compatibility with ILE C.
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.