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 |
---|---|
COLLATE | Returns a character string of length 256 comprising the 256 possible character values one time each in the collating order. |
COMMENT | Converts a character expression into a comment. |
COMPILEDATE | Returns a character string of length 27 containing the current date and time in the following format:
yyyymmddhhmmssttt yyyy is the current year. mm (in the date part) is the current month. dd is the current day of month. hh is the current hour. mm (in the time part) is the current minute. ss is the current second. ttt are the three digits of the tenth, hundredth and thousandths of the current second. Every part has leading zeros if necessary and there are no blanks. Example: 20210205171930537 |
COMPILETIME | Returns a character string of length 18 containing the current date and time in the following format:
dd_MMM_yy_hh.mm.ss _ represents a blank character. dd is the current day of month with a leading zero replaced by a blank. MMM is the current month in the form JAN, FEB, MAR, etc. yy is the current year (modulo 100). hh is the current hour. mm is the current minute. ss is the current second. Values of less then 10 of yy, hh, mm and ss use a leading zero. Example: 2 FEB 21 17.19.30 Be aware that in this example the string begins with a blank that replaces the leading zero. |
COPY(x,y) | Returns a character string consisting of y concatenated copies of the string x. The expression x must have CHARACTER type, otherwise it will be converted. y is an expression that specifies the number of repetitions and it must have FIXED type, otherwise it will be converted, and it must be greater than or equal to 1. If its value is 0, COPY returns a null string. |
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. |
DIMENSION(x,y) | Returns a FIXED value specifying the current extent of dimension y of x. The array x can't have less than y dimensions. y must have FIXED type, otherwise it will be converted, and it must be greater than or equal to 1. If omitted, it's value is 1, i.e. you can omit y only if x is one-dimensional. |
HBOUND(x,y) | Returns a FIXED value specifying the current upper bound of dimension y of x. The array x can't have less than y dimensions. y must have FIXED type, otherwise it will be converted, and it must be greater than or equal to 1. If omitted, it's value is 1, i.e. you can omit y only if x is one-dimensional. |
INDEX(x,y,z) | Returns a FIXED value indicating the starting position within the character expression x of a substring identical to character expression y. Optionally, z can be the position to start within x. If z is greater than the length of x then INDEX returns 0. |
LBOUND(x,y) | Returns a FIXED value specifying the lower upper bound of dimension x of x. The array x can't have less than y dimensions. y must have FIXED type, otherwise it will be converted, and it must be greater than or equal to 1. If omitted, it's value is 1, i.e. you can omit y only if x is one-dimensional. |
LENGTH(x) | Returns a FIXED value specifying the current length of a given character expression x. |
LOWERCASE (x) | Converts the alphabetic characters from A to Z to their lowercase equivalent. If x does not have CHARACTER type, it will be converted. |
MACCOL | Returns a FIXED value that represents the column where the outermost macro invocation starts in the source text. |
MACLMAR | Returns a FIXED value that represents the column number of the left source margin. |
MACNAME | Returns the name of the preprocessor procedure within which it is invoked. |
MACRMAR | Returns a FIXED value that represents the column number of the right source margin. |
MAX(x,y) | Returns the largest value from a set of two or more expressions. They must have FIXED type, otherwise they will be converted. |
MIN(x,y) | Returns the smallest value from a set of two or more expressions. They must have FIXED type, otherwise they will be converted. |
PARMSET(x) | Used to determine whether a specified parameter has been set on the invocation of a procedure. |
QUOTE(x) | Returns a character string that represents x as a valid quoted string. |
REPEAT(x,y) | Returns a character string consisting of (y + 1) concatenated copies of the string x. x must have CHARACTER type, otherwise it will be converted. y must have FIXED type, otherwise it will be converted, and it must be greater than or equal to 1. If it is equal to 1, REPEAT returns x. |
SOURCEFILE() | Returns a macro CHAR string containing the name of the source file where the macro preprocessor was invoked, and is intended primarily for diagnostics and debugging. Its results vary from one platform to another. |
SUBSTR(x,y[,z]) | Returns a substring of the character expression x, starting at position y with length z. |
SYSADDR | Returns a character string of '32' or '64' indicating whether the source has been processed by a 32-bit or 64-bit version of the macro preprocessor. |
SYSCHARSET | Returns a character string of 'ASCII' or 'EBCDIC' depending on the compile options in effect. |
SYSDIMSIZE | Returns 4, which is the maximum number of bytes needed to hold an index for an array. |
SYSENDIAN | Returns "LITTLE" on Little-Endian Platforms, and "BIG" on Big-Endian platforms. |
SYSOFFSETSIZE | Returns 4, which is the number of bytes that is needed to hold an offset. |
SYSPARM | Returns the value set by the DEFINE statement for SYSPARMSTRING. |
SYSPOINTERSIZE | Returns 4 in 32-bit mode and 8 in 64-bit mode. |
SYSTEM | Returns the -systemxxx option that the macro preprocessor was invoked with. The -systemmvs option will return MVS, -systemims - IMS and -systemcics - CICS. If no -systemxxx option was specified, it will return WIN on Windows, AIX on AIX, SOLARIS on Solaris, and LINUX on Red Hat Linux and SUSE Linux. |
SYSVERSION | Returns a character string containing the product name as well as the version, release, and modification level. The string is of length 22 and has different format depending on the system. On AIX it is "PL/I for AIX x.y", on Windows - "PL/I for Win* x.y" and on z/OS - "PL/I for z/OS Vx.Ry.Mz". |
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. |
TRIM(x[,y][,z]) | Returns a character string which is the output of trimming characters from one or both ends of an input string. |
UPPERCASE(x) | Converts the alphabetic characters from a to z to their uppercase equivalent. If x does not have CHARACTER type, it will be converted. |
VARIANT | Returns a character string specified on the command line. |
VERIFY(x,y[,z]) | Returns a FIXED value indicating the position in x of the leftmost character that is not in y. It also allows you to specify the location z within x at which to begin processing. x and y must have CHARACTER type, otherwise they will be converted. z must have FIXED type, otherwise it will be converted and it must be greater than 0 and no greater than 1 + LENGTH(x). If it is equal to LENGTH(x) + 1, the result is zero. The default value is 1. |
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)
Example 3 (SYSADDR).
fn: proc() options(main); %if sysaddr = 64 %then %do; put skip list ('64 bit'); %end; %else %do; put skip list ('32 bit'); %end; end fn;
Example 4 (COMPILEDATE):
%DCL CD CHAR; %CD = '"' || compiledate() || '"'; put skip list('Compile date is: ' || CD);
Example 5 (SYSPARM):
-define SYSPARM="HELLO WORLD"
on the command line will return:
"HELLO WORLD"
If the literal string contains /* or */ they are not replaced with /> and </.