ljustify2(string, length[, padChar])
Last updated September 16, 2012
Version: 0 | Requires: CF5 | Library: StrLib
Description:
This function mimics the lJustify function, but offers an optional third parameter to define the character to use for padding (if padding is necessary).
Return Values:
Returns a string, left-justified and padded to the specified field length
Example:
<cfoutput>
#ljustify2("foobar",10,".")#<br> <!--- outputs: foobar.... --->
#ljustify2("foobar",5,"-")#<br> <!--- outputs: foobar --->
</cfoutput>
Parameters:
Name | Description | Required |
---|---|---|
string | A string to justify within the specified field length | Yes |
length | The length of the field within which to justify the string | Yes |
padChar | Character to use for padding | No |
Full UDF Source:
/**
* Same as built-in LJUSTIFY, but allows optional parameter character to pad with.
* version 1.0 by Al Everett
*
* @param string A string to justify within the specified field length (Required)
* @param length The length of the field within which to justify the string (Required)
* @param padChar Character to use for padding (Optional)
* @return Returns a string, left-justified and padded to the specified field length
* @author Al Everett (everett.al@gmail.com)
* @version 0, September 16, 2012
*/
function ljustify2(string,length) {
var padChar = " ";
if (arrayLen(arguments) GT 2) {
padChar=left(arguments[3],1);
}
return arguments.string & repeatString(padChar,max(0,arguments.length - len(arguments.string)));
}
Search CFLib.org
Latest Additions
Raymond Camden added
QueryDeleteRows
November 04, 2017
Leigh added
nullPad
May 11, 2016
Raymond Camden added
stripHTML
May 10, 2016
Kevin Cotton added
date2ExcelDate
May 05, 2016
Raymond Camden added
CapFirst
April 25, 2016