Passing parameters

In an OPM or ILE call, a parameter is an expression that represents a value that the calling application passes to the API specified in the call.

HLL languages use the following methods for passing parameters:

By value, directly

The value of the data object is placed directly into the parameter list.

By value, indirectly

The value of the data object is copied to a temporary location. The address of the copy (a pointer) is placed into the parameter list. By value, indirectly is not done explicitly by the application programmer. It is done by the operating system at run time.

By reference

A pointer to the data object is placed into the parameter list. Changes made by the called API to the parameter are reflected in the calling application.

When you call an API, the protocol for passing parameters is to typically pass a space pointer that points to the information being passed. (This is also referred to as pass-by-reference.) This is the convention used by the control language (CL), RPG, and COBOL compilers. Care must be used in those languages that support pass-by-value (such as ILE C) to ensure that these conventions are followed. Refer to the appropriate language documentation for instructions. The parameter passing convention of pass-by-reference can be used in all programming languages. Some of the UNIX-type APIs require pass-by-value parameter passing. VisualAge® C++ for i5/OS™ also supports pass-by-value parameter passing.

HLL semantics usually determine when data is passed by value and when it is passed by reference. For example, ILE C passes and accepts parameters by value, directly, while for OPM and ILE COBOL and OPM and ILE RPG parameters are usually passed by reference. You must ensure that the calling program or procedure passes parameters in the manner expected by the called API. The OPM or ILE HLL programmer's guides contain more information on passing parameters to different languages.

The ILE languages support the following parameter-passing styles: