LJustify()
Left justifies characters in a string of a specified length.
LJustify( string=string, length=number );
Returns: String
Argument | Description |
---|---|
string
string,
required
|
A string or a variable that contains one |
length
number,
required
|
Length of field in which to justify string |
Examples
s = "";
res = lJustify(s, 4);
writeDump(len(res)); // length is 4
writeoutput("<pre>|#res#|</pre><hr>");
<span class="nv">s</span> <span class="o">=</span> <span class="s2">"abc"</span><span class="p">;</span>
<span class="nv">res</span> <span class="o">=</span> <span class="nf">lJustify</span><span class="p">(</span><span class="nv">s</span><span class="p">,</span> <span class="m">10</span><span class="p">);</span>
<span class="nf">writeDump</span><span class="p">(</span><span class="k">len</span><span class="p">(</span><span class="nv">res</span><span class="p">));</span> <span class="c">// length is 10</span>
<span class="nf">writeoutput</span><span class="p">(</span><span class="s2">"<pre>|</span><span class="s-Interp">#res#</span><span class="s2">|</pre><hr>"</span><span class="p">);</span>
<span class="nv">s</span> <span class="o">=</span> <span class="s2">"10"</span><span class="p">;</span>
<span class="nv">res</span> <span class="o">=</span> <span class="nf">lJustify</span><span class="p">(</span><span class="nv">s</span><span class="p">,</span> <span class="m">8</span><span class="p">);</span>
<span class="nf">writeDump</span><span class="p">(</span><span class="k">len</span><span class="p">(</span><span class="nv">res</span><span class="p">));</span> <span class="c">// length is 8</span>
<span class="nf">writeoutput</span><span class="p">(</span><span class="s2">"<pre>|</span><span class="s-Interp">#res#</span><span class="s2">|</pre>"</span><span class="p">);</span>
See also
- Formatting
- Strings
- RJustify()
- string.lJustify()
- Search Issue Tracker
- Search Lucee Test Cases (good for further, detailed examples)