AbsolutePaddingZeroes
Back to ListDescription: Pads a number to have static length of digits
FileMaker Prototype:
Set Variable [$res; ACF_Run("AbsolutePaddingZeroes"; long_number; int_digits)]
Category: UTILITY
Function source:
function AbsolutePaddingZeroes (long number, int digits)
string f = "%0"+digits+"ld";
return format ( f, number );
end
AbsolutePaddingZeroes is an direct replacement for the custom function with the same name found on Brian Dunnings huge custom functions library.
Example
Set Variable [$res; ACF_Run("AbsolutePaddingZeroes"; 123766; 10)]
Gives the output => 0000123766
This function uses a different approach than the function found on Brian's site:
AbsolutePaddingZeroes ( number ; digits )
Right( "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & number; digits )
The ACF format statement gives you this flex directly, and also allow you to have decimals in your number. Just changing the format and data type like this:
function AbsolutePaddingZeroesDec (float number, int digits)
string f = "%0"+digits+".2f";
return format ( f, number );
end
This will return:
Set Variable [$res; ACF_Run("AbsolutePaddingZeroesDec"; 123766.3123; 12)]
Gives the output => 000123766.31 