Preprocessor Built-In Functions

A reference to a preprocessor built-in function in input text is executed by the preprocessor only if the built-in function name is active. The functions are explained in the following table:

Function Name Use
COMPILETIME Returns a character string containing the current date and time in the following format:

DD MMM YY HH.MM.SS

COUNTER Returns a character string containing a decimal number. The returned number is 00001 for the first invocation and is incremented by one on each successive invocation.
INDEX(x,y) Returns a FIXED value indicating the starting position within the character expression x of a substring identical to character expression y.
LENGTH(x) Returns a FIXED value specifying the current length of a given character expression x.
PARMSET(x) Used to determine whether a specified parameter has been set on the invocation of a procedure.
SUBSTR(x,y[,z]) Returns a substring of the character expression x, starting at position y with length z.
TRANSLATE(s,t,x) Replaces occurrences in the character string s of a character in the specified string x with the corresponding translation character in translation string t and returns the resulting string.
VARIANT Returns a character string specified on the command line.

Examples

Example 1.

%ACTIVATE COMPILETIME;
%DECLARE TOC CHAR;
%TOC = ''''||COMPILETIME||'''';  
PUT LIST ('COMPILED AT' ||TOC); 
PUT SKIP;

The text generated by this example would be as follows:

PUT LIST('COMPILED AT '||' 14 NOV 93 15.53.12'); 
PUT SKIP;

Example 2.

%DECLARE XXX CHAR, COUNTER BUILTIN, I FIXED;
%DO I = 1 TO 4;
%XXX = 'DECLARE NAME_'|| COUNTER || 'FIXED BIN(31);'; 
XXX
%END;

The text generated by this example would be as follows:

DECLARE NAME_00001 FIXED BIN(31); 
DECLARE NAME_00002 FIXED BIN(31) 
DECLARE NAME_00003 FIXED BIN(31) 
DECLARE NAME_00004 FIXED BIN(31)