PaddingFixedLength
Back to ListDescription: Returns a fixed width text string padded with padChar. If len is negative, do left justified text. x
FileMaker Prototype:
Set Variable [$res; ACF_Run("PaddingFixedLength"; string_text; string_padChar; int_len)]
Category: UTILITY
Function source:
function PaddingFixedLength ( string text, string padChar, int len)
int tlen = length(text);
if ( len< 0) then
// Left justified field.
len = -len;
return text + ((tlen>=len)?"":padChar*(len-tlen));
end if
return ((tlen>=len)?"":padChar*(len-tlen))+text;
end
PaddingFixedLength is an utility function to be used where fixed length fields are needed. It can handle both left and right justified text or numbers. The "len" parameter can be negative, meaning left justified text. The "padChar" parameter is a single character used as padding where padding is needed.
It does not cut text if its length exceeds the target length, hovever this can slightly be modified if that is needed. Adding:
text = substring(text,0,len);
just after the function statement.
Example
ACF_Run ("PaddingFixedLength"; "2000", "0", 10)
=> 0000002000
ACF_Run ("PaddingFixedLength"; "Title-1 ", "=", -40)
=> Title-1 ================================ 