NET/MASTER Network Control Language (NCL) Reference Manual
JUSTIFY
Built-in Functions
4–46 106126 Tandem Computers Incorporated
JUSTIFY The JUSTIFY built-in function inserts spaces or a user-specified pad character into a
string.
NCL first normalizes the string by removing all leading and trailing spaces. Next, any
multiple occurrences of spaces within the given string are replaced by a single space
character. Finally, the pad character then replaces the spaces, evenly from left to right,
to the required specified length of the string. Depending on the specified length of the
target string, multiple instances of the specified pad character can be inserted between
each separate word of the source string; see the examples given at the end of this
description.
JUSTIFY(
string
,
length
[,
pad
] )
string
specifies the string to be justified.
length
specifies the length of the justified output string. This operand must always be a
non negative whole number.
If
length
is less than the length of the string, the string is truncated on the right to
the specified value of
length
, and trailing spaces are removed.
pad
specifies the pad character to be used. The default is a space. If specified, this
operand must be only one character in length.
Considerations
If NCL is unable to insert the same number of pad characters between each word,
it uses a lesser number between the first and second words of the string. This is
shown in the fourth example following. NCL can truncate a string, as shown in
the second example following.
See also SPACE, which removes extraneous spaces from a string and optionally
replaces them with another character.
Examples
In the following example, the string “The blue sky” is justified to 14 characters in
length. The output string is “The blue sky”; it has two spaces between each word:
&A = The blue sky
&B = 14
&RESULT = JUSTIFY(&A,&B)