One hurdle that we can come across, is the styling of number field as we do it from FM Inspector. (styling of numbers can also be done through HTML , but this example shows how to format from FM side)
Example:- Decimal = 2 , thousand separator = , (setting from inspector)
For decimal =3 , the number becomes as follows:-
15.2345 = 15.234 (truncate function can achieve this)
15 = 15.000
15.1 = 15.100
15.12 = 15.120
So , for this number format conversion , i have devised a custom function ,
addingPrecision(number:precsn)
number= number to be formatted
precsn=the number of digits after decimal to be formatted.
——————————————————————————
Let (
[ data = GetAsText ( number ) ;
posnDecimal = Position ( data ; “.” ; 1 ; 1 );
len = Length ( data );
digitAfterDecimal = Middle ( data ; posnDecimal +1 ; len – posnDecimal +1 );
digitAfterDecimalTotal = Length (digitAfterDecimal);
new = Case ( IsEmpty ( data ) or data = “0” ;”0.” & repeatText ( “0” ; precsn ; 1 );
Int ( data ) = data ; data & “.” & repeatText ( “0” ; precsn ; 1 );
digitAfterDecimalTotal ≥ precsn ; Truncate ( data ; precsn ) ;
digitAfterDecimalTotal < precsn ; data & repeatText ( “0” ; precsn – digitAfterDecimalTotal ; 1 )
)
];
new
)
——————————————————————————
repeatText(txt;rept;count1)
txt = text to be repeated
rept= number of repetitions
count1 = always 1
——————————————————————————
Let (
[
// nothing requires here
];
If ( count1 = rept ;txt ; txt & repeatText(txt;rept;count1+1) )
)
——————————————————————————
