Using the IN operator - problem with decimal values

janmib
Member Posts: 8
I have a code block like this:
IF Customer.verdi<>0 THEN BEGIN
IF verdi IN [0,1..3,0] THEN range:=1 ELSE
IF verdi IN [3,1..4,0] THEN range:=2 ELSE
IF verdi IN [4,1..5,0] THEN range:=3 ELSE
IF verdi IN [5,1..20,9] THEN range:=4 ELSE
range:=5;
I compiles but does not work as planned. The field verdi is a decimal field.
We use comma as a decimal separator. Range is not set according to the
value of customer verdi.
Any tips - maybe a better way ?
IF Customer.verdi<>0 THEN BEGIN
IF verdi IN [0,1..3,0] THEN range:=1 ELSE
IF verdi IN [3,1..4,0] THEN range:=2 ELSE
IF verdi IN [4,1..5,0] THEN range:=3 ELSE
IF verdi IN [5,1..20,9] THEN range:=4 ELSE
range:=5;
I compiles but does not work as planned. The field verdi is a decimal field.
We use comma as a decimal separator. Range is not set according to the
value of customer verdi.
Any tips - maybe a better way ?
0
Comments
-
IF Customer.verdi<>0 THEN BEGIN IF verdi > 0,1 AND verdi <= 3,0 THEN range:=1 ELSE IF verdi > 3,1 AND verdi <= 4,0 THEN range:=2 ELSE IF verdi > 4,1 AND verdi <= 5,0 THEN range:=3 ELSE IF verdi > 5,1 ABD verdi <= 20,9 THEN range:=4 ELSE range:=5;
0 -
or...
if customer.verdi <> 0 then case true of customer.verdi <= 3 : Range := 1 ; customer.verdi <= 4 : Range := 2 ; customer.verdi <= 5 : Range := 3 ; customer.verdi <= 20.9 : Range := 4 ; else Range := 5 ; end ;
0 -
-
Try
IF Customer.verdi<>0 THEN BEGIN IF verdi IN [0.1..3.0] THEN range:=1 ELSE IF verdi IN [3.1..4.0] THEN range:=2 ELSE IF verdi IN [4.1..5.0] THEN range:=3 ELSE IF verdi IN [5.1..20.9] THEN range:=4 ELSE range:=5;
The decimal separator is . not , - , is value separator. It means your code have meaningif verdi is [0 or (1..3) or 0] ...
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