Filter as a variable

Nabuco
Member Posts: 65
Hi all
Being somewhat novice in C/SIDE i have a Little problem.
Having a Var - code120 - value: <>TRACK
When this Var has a content I wish to extend it to exclude all blanks. Therefore I has coded:
IF Var <>'' THEN
Var := Var + '|' + '<>''';
Giving the result: <>TRACK|<>'
Missing one ' as the last - why is that - does anyone know the solution?
Being somewhat novice in C/SIDE i have a Little problem.
Having a Var - code120 - value: <>TRACK
When this Var has a content I wish to extend it to exclude all blanks. Therefore I has coded:
IF Var <>'' THEN
Var := Var + '|' + '<>''';
Giving the result: <>TRACK|<>'
Missing one ' as the last - why is that - does anyone know the solution?
0
Answers
-
Hi
2 problems here...
First, if you want a single quote within a string you put 2 single quotes, so instead of ''' you would have '''' therefore to have a string of 2 single quotes you would have 6 consecutive single quotes - 1 start quote, 2 quotes for the first single quote, 2 more quotes for the second single quote and then a final quote to close the string.
Second, if you want to exclude blanks then you should have an AND (&) not an OR (|)
Therefore your code should be....
IF Var <>'' THEN
Var := Var + '&' + '<>'''''; // that's 5 quotes at the end and 1 quote just before the <>
Giving the result: <>TRACK&<>''
Regards
Kishor0 -
You have to write two single quotation marks within a string literal to get one in the data. This is C/AL's way of quoting them. Otherwise it was treated as the closing string delimiter.
Also you will want to think again about your filter expression. Does it really do what you intend (because it will not do what you wrote you want to achieve).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