Preprocessor Procedures

Unfortunately much of the IBM documentation of the Preprocessor is vague. This information should all be prefixed by "I assume", since most of it is derived by running tests using IBM PL/I for OS/2.

Arguments for Preprocessor Procedures

Preprocessor arguments are handled differently depending on whether a procedure is called from a preprocessor statement or from "open code" (not a preprocessor statement or within a preprocessor procedure).

    • Arguments to procedures called from a preprocessor statement must be preprocessor expressions, preprocessor variables, or character strings (in quotes).

  • Arguments to procedures called from open code may be an arbitrary sequence of "things" delimited by commas. Each argument is treated as if it were a character string and may be subject to replacement if any of the elements of the argument is a preprocessor variable. For example:

    • %ppproc1: PROCEDURE(parm) returns(CHARACTER);

    • ...

    • %END ppproc1;

    • %ACTIVATE ppproc1;

      • %DECLARE ppvar1 CHARACTER;

      • %ppvar1 = 'ABC';

      • normal_variable = ppproc1( xyz ppvar1 ); /* non-preprocessor statement */

    • will scan the string "xyz ppvar1" (without the quotes) and replace ppvar1 with ABC. Therefore ppproc1 will be called with the argument "xyz ABC" (again without the quotes). Leading and trailing blanks will be trimmed from each argument, but imbedded blanks will be left.

    • Likewise, if the name of a preprocessor procedure is found in the argument its name will be replaced by the result of a call to the procedure.

    • Elements of arguments have to be valid PL/I tokens for replacement to occur, following the rules for a standard PL/I variable name, that is ppvar1 will be replaced above, but will not be replaced in "ppvar1" (with the quotes) or in ppvar123.

    • If anyone has corrections or additions to this information, please let me know.