StartsWith-Filter

Dosihris
Member Posts: 23
Hi,
is there a way to find out whether a name starts with "Ha"?
i have a boolean variable "isrightname" and i want to do something like:
isrightname := Name.StartsWith("Ha");
or
isrightname := Name = 'Ha*';
Is there something like that?
is there a way to find out whether a name starts with "Ha"?
i have a boolean variable "isrightname" and i want to do something like:
isrightname := Name.StartsWith("Ha");
or
isrightname := Name = 'Ha*';
Is there something like that?
0
Comments
-
MyTempTable.Field := 'Haramadaka'; MyTempTable.INSERT; MyTempTable.SETFILTER(Field,'%1*','Ha'); isrightname := not MyTempTable.ISEMPTY;
8)0 -
or, if you loop through a table where the Names are stored and you want in these table set the boolean "isrightname", then u can use also this:
MyTable.setcurrentkey(YourNeededKey); MyTable.setrange("Needed Field","NeededValue"); if MyTable.findset(true) then begin repeat if (Strlen(MyTable.FieldToCheck) >=2) then begin //Uppercase,Lowercase MyTable.isrightname := (MyTable.FieldToCheck[1] in [72,104]) and (MyTable.FieldToCheck[2] in [65,97]); MyTable.modify; //also possible is to use a string function like strpos() end; until MyTable.next = 0; end;
if you will set it only on a variable on the form, and u diesn't save the variable value, u can use:isrightname := (FieldToCheck[1] in [72,104]) and (FieldToCheck[2] in [65,97]);
orMyTableasVariable.setrange(PromaryKeyField,PrimarykeyOftheRecFromtheCard); MyTableasVariable.setfilter("FieldToCheck",'%1','Ha*') ; //also possible with the @ infront if the Ha isrightname := not MyTableasVariable.isempty;
RegardsDo you make it right, it works too!0 -
garak wrote:or, if you loop through a table where the Names are stored and you want in these table set the boolean "isrightname", then u can use also this:
...
MyTable.reset ; Mytable.modifyall(IsRightname,true) ; MyTable.setfilter("Needed Field",'@%1*','Ha') ; // Leave out the @ for case-sensitive Mytable.modifyall(IsRightname,true) ;
0 -
are u sure that this will work?MBerger wrote:
MyTable.reset ; Mytable.modifyall(IsRightname,true) ; MyTable.setfilter("Needed Field",'@%1*','Ha') ; // Leave out the @ for case-sensitive Mytable.modifyall(IsRightname,true) ;
The first modify: Mytable.modifyall(IsRightname,true) ; <-- u modify all recs in the table
MyTable.setfilter("Needed Field",'@%1*','Ha') ; <-- i mean i must be: MyTable.setfilter("Needed Field",'%1','@Ha*') ;
;-)
RegardsDo you make it right, it works too!0 -
Thank you guys for that interesting solutions. i never thought that i have to redevelop half NAV to just get this simple Filter in the text field.
But many of you advised SETFILTER. Well, let me shortly explain what i want to do and than i think you know that SETFILTER is just not really possible.
I use NAV 2009 RTC, the contact list. I have set a style to the name column (so all the names in the list are styled green.) But i dont want that all names are green, i only want names green that starts with "Hans". So there is a StyleExpr field, where you can set a boolean expression. In MSDN i read that i ofcourse cant just write in that field "Name = 'Hans*'". I have to set a global boolean variable and in the function "OnAfterGetRecord" i have to evaluate every single name and find out whether it starts with hans. If so i have to set this global variable to true, otherwise to false. and this global variable i can use in StyleExpr. So SETFILTER is not helpfull for me.
All this works when i write isrightname := Name = 'Hans Viller';
But than only Hans Viller is styled. But i need all Hanses... :-)0 -
garak wrote:0
-
Dosihris wrote:Thank you guys for that interesting solutions. i never thought that i have to redevelop half NAV to just get this simple Filter in the text field.
But many of you advised SETFILTER. Well, let me shortly explain what i want to do and than i think you know that SETFILTER is just not really possible.
I use NAV 2009 RTC, the contact list. I have set a style to the name column (so all the names in the list are styled green.) But i dont want that all names are green, i only want names green that starts with "Hans". So there is a StyleExpr field, where you can set a boolean expression. In MSDN i read that i ofcourse cant just write in that field "Name = 'Hans*'". I have to set a global boolean variable and in the function "OnAfterGetRecord" i have to evaluate every single name and find out whether it starts with hans. If so i have to set this global variable to true, otherwise to false. and this global variable i can use in StyleExpr. So SETFILTER is not helpfull for me.
All this works when i write isrightname := Name = 'Hans Viller';
But than only Hans Viller is styled. But i need all Hanses... :-)
My solution is quick - you just enter one line into temporary table and see if the value is inside your filter. This will return you the TRUE-FALSE you need. If you create function for that, you can use it in OnAfterFormat trigger to know if you need to color the name or not. Where is problem? ;-)0 -
What about:
IsRightName := (COPYSTR(Name, 1, 4) = 'Hans');
0 -
:-)
It is simple... :whistle:
That's true that in this case no more is needed. My example was originally for more complex filters...0 -
PeterD's version is the best. The the way with the temporary table is ok, but i need another global variable. I just want it as simple as possible.
Thank you guys.0 -
this way you could make Fritz green too instead of only Hans.
also what you match could be longer
leave out the lowercase function calls if you need to match case
DoesStartWith(startswith : Text[10];Name : Text[30]) : Boolean
exit(lowercase(copystr(name,1,strlen(startswith))) = lowercase(startswith));
Steve0
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