Defines a procedure entry and specifies the parameters of the procedure, if any.
%label:[label:]... PROCEDURE[(ident[,ident]...)] [STATEMENT][RETURNS(CHARACTER|FIXED|BIT)][KEYS[(ident[,ident]...)]];
Abbreviation(s): %PROC for %PROCEDURE.
ident is a PL/I name.
%DECLARE (A,B,C) CHARACTER; %ACTIVATE CAT; %A = 'AAA'; %B = 'BBB'; %C = 'CCC'; RES_STRING_3 = CAT(A,B,C); RES_STRING_2 = CAT (A,B); RES_STRING_1 = CAT(A); %CAT: PROCEDURE(X,Y,Z) RETURNS(CHAR); DECLARE (X,Y,Z) CHAR; DECLARE S CHAR; IF PARMSET(Z) THEN S = ''''||X||Y||Z||''''; ELSE IF PARMSET(Y) THEN S = ''''||X||Y||''''; ELSE S = ''''||X||''''; RETURN(S); %END CAT;
The text generated by this example would be as follows:
RES_STRING_3 = 'AAABBBCCC'; RES_STRING_2 = 'AAABBB'; RES_STRING_1 = 'AAA';
This example also shows how to generate a character string constant using the preprocessor. To do so, use four successive apostrophes, followed by the concatenation symbol, followed by the expression for the desired character string constant, followed by another concatenation symbol, followed by four more apostrophes.
Description
The %PROCEDURE statement is used in conjunction with a %END statement to delimit a preprocessor procedure. Such a preprocessor procedure is an internal function procedure that can be executed only by the preprocessor.
One of the RETURN attributes, CHARACTER, FIXED, or BIT, must be specified in the RETURNS attribute list to indicate the type of value returned by the function procedure. There can be no default.
The preprocessor statements ASSIGNMENT, DECLARE, DO, GOTO, IF, NULL, RETURN, and NOTE can be used within a preprocessor procedure. Inside the preprocessor procedure the % symbols are omitted.