Tutorial on FORMAT function and property?

girish.joshi
Member Posts: 407
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
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
-
so you're trying to make
1.29
100.50
20.39
appear like
0000129
0010050
0002039
am I correct?0 -
Yeah that's right. I would also add that I'm trying to make
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 Savatage0 -
Read these maybe they can help you....
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 decimal0 -
Thanks again, Savatage.
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.0 -
dec is of type decimal
dec := 1;
DELCHR(format(dec,0,'<Integer,5><Filler,0><Decimal,3>'),'=','.')
result is 00001000 -
wow. exactly what I was looking for.0
-
This particular problem, decimals being converted into strings with implied decimal points and padding leading zeros, comes up frequently during integrations.
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.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions