LJUST: Left-Justifying a String

How to:

Available Languages: reporting

LJUST left-justifies a character string within a field. All leading spaces become trailing spaces.

LJUST will not have any visible effect in a report that uses StyleSheets (SET STYLE=ON) unless you center the item.

There is a version of the LJUST function that is available only in the Maintain language. For information on this function, see LJUST: Left-Justifying a Character String (Maintain).

Syntax: How to Left-Justify a Character String

LJUST(length, source_string, output)

where:

length

Integer

Is the number of characters in source_string and output, or a field that contains the length.

source_string

Alphanumeric

Is the character string to be justified, or a field or variable that contains the string.

output

Alphanumeric

Is the name of the field that contains the result, or the format of the output value enclosed in single quotation marks.

Example: Left-Justifying a String

The following request creates the XNAME field in which the last names are not left-justified. Then, LJUST left-justifies the XNAME field and stores the result in YNAME.

SET STYLE=OFF
DEFINE FILE EMPLOYEE
XNAME/A25=IF LAST_NAME EQ 'BLACKWOOD' THEN '    '|LAST_NAME ELSE
''|LAST_NAME;
YNAME/A25=LJUST(15, XNAME, 'A25');
END
 
TABLE FILE EMPLOYEE
PRINT LAST_NAME XNAME YNAME
END

The output is:

LAST_NAME         XNAME                  YNAME    
---------         -----                  -----    
STEVENS            STEVENS               STEVENS  
SMITH              SMITH                 SMITH    
JONES              JONES                 JONES    
SMITH              SMITH                 SMITH    
BANNING            BANNING               BANNING  
IRVING             IRVING                IRVING   
ROMANS             ROMANS                ROMANS   
MCCOY              MCCOY                 MCCOY    
BLACKWOOD             BLACKWOOD          BLACKWOOD
MCKNIGHT           MCKNIGHT              MCKNIGHT 
GREENSPAN          GREENSPAN             GREENSPAN
CROSS              CROSS                 CROSS