Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding the next match after SEEK 7

Status
Not open for further replies.

keepingbusy

Programmer
Apr 9, 2000
1,470
GB
Hi all

How do I find the next match using SEEK? For example, if I enter the name DAVIES and the first record found is NOT the correct one, I need to continue searching. I've tried CONTINUE etc but that doesn't work.

Sometime back (thread184-843495) it was suggested that SEEK is the quickest way to search. I did try LOCATE but this is very slow when you have 5000+ records. The problem here is that the table contains both forename and surname in the same field (Dont shoot the messenger, it was nothing to do with me!)

This is what I have so far:

* mline01 is the variable for the NAME
Code:
SET ORDER TO LINE01
GO TOP
SET NEAR ON
SEEK TRIM(mline01)
IF FOUND()
  THISFORM.GRID1.SETFOCUS()
  nmessage=MESSAGEBOX("Found: "+ ;
  TRIM(LINE01)+" - "+TRIM(TRANSACT)+ ;
  ", Continue Search?"+SPACE(5), ;
  4+32+256,"System Message")
  IF nmessage=7

*  What goes here to continue search?
*  Or any alternative method

ENDI

Look forward to any replies
Lee

VisFox Version 6 User / Windows ME
 
Hi Lee,

You asked
If my variable is mline01, how would you incorporate this into your suggestion?

Well, it was more a suggestion for the general problem to find next matches after a seek. In your special case this doesn't work, as you search for TRIM(mline01) $ line01. As there is no way to create an index for such search conditions it's not possible.

If you'd rather search for table.line01 = ALLTRIM(mline01), which is a search for "lines beginning with", if EXACT is set OFF, then this would work this way:

Code:
trimline01 = ALLTRIM(mline01)
...
if Seek(trimline01)
Scan Rest While table.line01=trimline01
   ...
Endscan

I understand, that this is not what you need, but it would answer the thread's subject.

Bye, Olaf.
 
foxdbs and Olaf, thanks for your posts

Lee

VisFox Version 6 User / Windows ME
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top