JUSTIFY
(Non-SAA Function)
returns string formatted by adding pad characters between blank-delimited words to justify to both margins. This is done to width length (length must be a positive whole number or zero). The default pad character is a blank.
The first step is to remove extra blanks as though SPACE(string) had been run (that
is, multiple blanks are converted to single blanks, and leading and
trailing blanks are removed). If length is
less than the width of the changed string, the string is then truncated
on the right and any trailing blank is removed. Extra pad characters are then added evenly from left to right
to provide the required length, and the pad character replaces the blanks between words.
Here are some
examples:
JUSTIFY('The blue sky',14) -> 'The blue sky'
JUSTIFY('The blue sky',8) -> 'The blue'
JUSTIFY('The blue sky',9) -> 'The blue'
JUSTIFY('The blue sky',9,'+') -> 'The++blue'