Justify

Justifies characters in a string of a specified length, either left or right.

Method Signature

Justify(string=[string], length=[integer])

Arguments

Argument
Type
Required
Description
Default

string

string

true

The string to justify.

length

integer

true

The specified length of the resulting string.

Examples

Tag Example

<bx:set length = 10 >
<bx:set result = RJustify( "abc", length ) >
<bx:output>
    <pre>~#result#~</pre>
</bx:output>

Additional Examples

Run Example

writeDump( label="", var=RJustify( "", 4 ) );
writeDump( label="", var=RJustify( "abc", 1 ) );
writeDump( label="", var=RJustify( "abc", 5 ) );
writeoutput( "<hr>" );
s = "";
res = rJustify( s, 4 );
writeDump( len( res ) ); // length is 4
writeoutput( "<pre>|#res#|</pre><hr>" );
s = "abc";
res = rJustify( s, 10 );
writeDump( len( res ) ); // length is 10
writeoutput( "<pre>|#res#|</pre><hr>" );
s = "10";
res = rJustify( s, 8 );
writeDump( len( res ) ); // length is 8
writeoutput( "<pre>|#res#|</pre>" );

Last updated

Was this helpful?