Alan
11/27/2023, 11:44 AMaliaspooryorik
Alan
11/27/2023, 11:56 AMAlan
11/27/2023, 11:56 AMAlan
11/27/2023, 11:58 AM/**
* Left pads a string with a specified character to a specified length.
*
* @param original The original string to pad.
* @param length The length to pad to.
* @param padChar The character to pad with.
* @return The padded string.
*/
public string function leftPad(string original, numeric length, string padChar=" ") {
// Calculate the number of padding characters needed
numeric padLength = length - len(original);
// If no padding is needed, return the original string
if (padLength <= 0) {
return original;
}
// Generate the padding string
string padding = repeatString(padChar, padLength);
// Return the padded string
return padding & original;
}aliaspooryorik
aliaspooryorik
repeatString or do some kind of loopDave Merrill
11/27/2023, 1:20 PMAlan
11/27/2023, 1:21 PMrodyon
11/27/2023, 6:40 PMrodyon
11/27/2023, 6:40 PMDave Merrill
11/27/2023, 8:08 PMDave Merrill
11/27/2023, 8:09 PM