Class: String
Description
This method justifies (left, center, or right) and pads a string within a field. This method replaces the $JUSTIFY() function.
Syntax
StringObject.justify(Number fieldLength,Number justifyOption,
String padCharacter,Boolean truncate)
Parameters
fieldLength |
The length of the field to justify. |
justifyOption |
A value that indicates how the String object's value is justified.
If not specified, the default is right justification. |
padCharacter |
The character that pads the field on either side of the string, as appropriate. If not specified, the pad character is a space. If padCharacter contains more than one character, the first character is used. |
truncate |
An option that indicates whether the result is truncated to match the specified field length.
|
Returns
A justified version of the string.
When Became Available
v7.0
Example
type String TXT = "Enjoy, have fun!")
// right justify examples
type String J1 = TXT.justify(20) // adds 4 spaces
type String J2 = TXT.justify(20,7) // same as prev.
type String J3 = TXT.justify(20,7,"-") // adds 4 dashes
type String J4 = TXT.justify(20,7,"-",1) // same as prev.
// justify when field it too small
set J1 = TXT.justify(10) // TXT unchanged
set J2 = TXT.justify(10,7) // same as prev.
set J2 = TXT.justify(10,0) // same as prev.
set J2 = TXT.justify(10,-7) // same as prev.
set J3 = TXT.justify(10,7,"-") // same as prev.
set J4 = TXT.justify(10,7,"-",0) // same as prev.
set J4 = TXT.justify(10,7,"-",1) // "Enjoy, hav"
// left justify examples
set J2 = TXT.justify(20,-7) // appends 4 spaces
set J3 = TXT.justify(20,-7,"*") // appends 4 asterisks
set J4 = TXT.justify(20,7,"*",1) // same as prev.
// center examples
set J2 = TXT.justify(20,0) // both sides 2 spaces
set J3 = TXT.justify(20,0,"*") // same with asterisks
set J4 = TXT.justify(20,7,"*",1) // same as prev.