The REVERSE function reverses the characters in a string. This reversal includes all trailing blanks, which then become leading blanks. However, in an HTML report with SET SHOWBLANKS=OFF (the default value), the leading blanks are not visible.
REVERSE(length, source_string, output)
Is the number of characters in source_string and output, or a field that contains the length.
Is the character string to reverse enclosed in single quotation marks, or a field that contains the character string.
Is the name of the field that contains the result, or the format of the output value enclosed in single quotation marks.
In the following request against the EMPLOYEE data source, the REVERSE function is used to reverse the characters in the LAST_NAME field to produce the field named REVERSE_LAST. In this field, the trailing blanks from LAST_NAME have become leading blanks. The TRIM function is used to strip the leading blanks from REVERSE_LAST to produce the field named TRIM_REVERSE:
DEFINE FILE EMPLOYEE REVERSE_LAST/A15 = REVERSE(15, LAST_NAME, REVERSE_LAST); TRIM_REVERSE/A15 = TRIM('L', REVERSE_LAST, 15, ' ', 1, 'A15'); END TABLE FILE EMPLOYEE PRINT REVERSE_LAST TRIM_REVERSE BY LAST_NAME END
The output is:
LAST_NAME REVERSE_LAST TRIM_REVERSE --------- ------------ ------------ BANNING GNINNAB GNINNAB BLACKWOOD DOOWKCALB DOOWKCALB CROSS SSORC SSORC GREENSPAN NAPSNEERG NAPSNEERG IRVING GNIVRI GNIVRI JONES SENOJ SENOJ MCCOY YOCCM YOCCM MCKNIGHT THGINKCM THGINKCM ROMANS SNAMOR SNAMOR SMITH HTIMS HTIMS HTIMS HTIMS STEVENS SNEVETS SNEVETS