Pad
Description
Pad adds extra padding on the ends of an output value. This function is useful for when an output is required to have a specific length, but the extracted value is too short. Also, if your task requires data to be right or
left justified, pad allows you to add spaces on the left or right as appropriate.
Syntax
target.strlib.pad( str, length, "pad_with", left, right );
str: String that needs padding
length: Length of the new padded string
pad_with: Specify character which will be used to pad
left: Boolean value, will there be padding on the left (true or false)
right: Boolean value, will there be padding on the right (true or false)
Return value
This function returns a string
Sample
'---------- Start ----------
Function Start
Dim str, str2
str = "pad"
str2 = target.strlib.Pad( str, 9, "*", true, true )
trg.Message( str2 )
End Function
Here we are padding the input string with asterisks, the initial string length is 3, the desired length is nine, and there will be padding on both sides yielding an output string of ***pad***.
See also