Is there anywhere that I can get a really complete description of what the FORMAT function and property can do? The help file seems like a good start, but isn't really comprehensive.
In particular, my problem is I have a decimal field, and I want it formatted to a fixed length, with leading zeros, and an implied decimal point. I could code this from scratch, but it seems like a good opportunity to learn the Navision tools better.
Thanks for taking a look,
Girish Joshi
0
Comments
1.29
100.50
20.39
appear like
0000129
0010050
0002039
am I correct?
http://www.BiloBeauty.com
http://www.autismspeaks.org
1
appear as
0000100
And the real key for me would be to do it with as much of the navision standard library as possible.
Thanks Savatage
Initalizing a string to certain characters
http://www.mibuso.com/forum/viewtopic.php?t=8157
leading zeros for decimals
http://www.mibuso.com/forum/viewtopic.php?t=7807
*of couse if you multiply your # by 100 first that rids the decimal
http://www.BiloBeauty.com
http://www.autismspeaks.org
I did know how to accomplish the task using padstr etc, but what I was really hoping for was to be able to accomplish the task with format. From the help files, I get the impression that its very powerful, but there isn't enough information there for me to really know how to use it.
dec := 1;
DELCHR(format(dec,0,'<Integer,5><Filler,0><Decimal,3>'),'=','.')
result is 0000100
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
I think ara3n's approach is the best here -- uses Navision code and is concise.
Savatage's solution requires code for you to special case '0'. That is to say, multiplying by 100 to get rid of the decimals (to implement the implied point) isn't a good because if your value is 0, then 0*100=0 and it doesn't work.
The WORST, god help you if you do, solution is to code your own parsing routing.