Options

Filter problem

kenlkenl Member Posts: 182
Hello,

I have a case like this:

I have a field to store location code filter. (The value may be 'w1..w5' , 'w1|w5..w10' or any valid field filter)

Now given a location code (eg. w2), I would like to know, whether the location is match within the location code filter.

How can I do it? Any suggestion?

Thanks.

Comments

  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Hi,

    First thing I Think of:
    Create Temporary Location Table
    
    Location.Setrange(Code, LocationFilter);
    If Find('-') then repeat
      CopyToTempTable
    Until next = 0;
    
    if templocation.get(w2) then
      IsInFilter;
    
    

    Maybe to complex? I think it should work
  • Options
    kinekine Member Posts: 12,562
    take Location table as temporary table, clear it, insert your value, apply filter, if result is empty, it is not within, if you get one record, it is within...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Also Possible (2nd Tought)
    locationisinfilter := FALSE;
    
    Location.Setrange(Code, LocationFilter); 
    If Find('-') then repeat 
      if location.code = 'W2' then
       locationisinfilter := TRUE;
    Until (next = 0) or locationisinfilter; 
    
    

    Know you have 3 options :D
  • Options
    kinekine Member Posts: 12,562
    3rd option:
    Location.SetFilter(Code, LocationFilter);
    Location.FILTERGROUP(1);
    Location.Setrange(Code,'W2');
    Location.FILTERGROUP(0);
    
    if Location.ISEMPTY then
      //Is not within
    else
      //Is within
    

    It will do this filtering: LocationFilter AND 'W2'
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    WaldoWaldo Member Posts: 3,412
    Didn't try this out, but may be something like this (4th option):
    Location.SetFilter(Code, LocationFilter); 
    
    Location.Code := 'W2';
    if NOT Location.FIND('=') then 
      //Is not within 
    else 
      //Is within
    

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • Options
    kenlkenl Member Posts: 182
    Hello all,

    Thanks for all of your suggestion. :D
Sign In or Register to comment.