Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Find command unexpected operation
Sun, Sep 2 2012 1:28 AMPermanent Link

Jeff Newlin

Lightspeed

I'm enjoying working with the datasets and EWB but I'm stuck on something silly. I'm trying to get a "nearest match" on a search of the CustomerID field in the sample Dataset Customer. This is my code snip -


  With Customer do
  begin
     Columns['CustomerID'].SortDirection := sdAscending ;
     SortCaseInsensitive := TRUE ;
     Sort ;
     InitFind ;
     Columns['CustomerID'].AsString := 'D'  ;

     if Find(TRUE,TRUE) then
     begin
        Memo.Lines.Add('Found ' +  Columns['CompanyName'].AsString ) ;
     end
     else Memo.Lines.Add('Not Found') ;
  end ;

My problem is that it FIND only returns true on an  exact match - as if the first passed parameter was FALSE instead of TRUE. It doesn't seem to operate any differently if it's false or true on that first parameter. To be specific if I'm searching using  'D' - shouldn't it consider 'DM' the nearest match?

I must be missing something here.

Thank you!
Jeff
Mon, Sep 3 2012 1:50 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Jeff,

<< My problem is that it FIND only returns true on an  exact match - as if
the first passed parameter was FALSE instead of TRUE. It doesn't seem to
operate any differently if it's false or true on that first parameter. To be
specific if I'm searching using  'D' - shouldn't it consider 'DM' the
nearest match? >>

Nearest-match searches don't return True unless the search resulting in an
actual match.  IOW, performing a nearest-match search doesn't change the
result of the search, only how the row pointer moves in the dataset after
the search.

If you have any other questions, please let me know.

Tim Young
Elevate Software
www.elevatesoft.com
Image