Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Search a table for a string
Message
 
 
To
21/07/2003 08:32:15
Mike Yearwood
Toronto, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00811295
Message ID:
00812187
Views:
44
Hey Mike!

Thanks for the time trials. Looks like a left to right, top to bottom search is indeed faster than a top to bottom left to right search. In thinking about this, it does make sense.

>Hiya Mark!
>
>After looking at your code, I wondered why you used locate. Since there's no way to optimize substring searching, I guessed it would be quicker to do this...
>
>
LPARAMETERS tcString
>IF VARTYPE(m.tcString) <> 'C'
>   RETURN -1
>ENDIF
>LOCAL lnI, lnRec, lcString
>lcString = LOWER(m.tcString)
>lnRec = 0
>SCAN REST WHILE m.lnRec = 0
>  FOR lnI = 1 TO FCOUNT()  && assuming table is open in the current workarea
>    IF INLIST(TYPE(FIELD(m.lnI)), 'C', 'M')
>       IF m.lcString $ LOWER(EVALUATE(FIELD(m.lnI)))
>         lnRec = RECNO()
>         EXIT
>       ENDIF
>    ENDIF
>  ENDFOR
>ENDSCAN
>IF m.lnRec#0
>  GO m.lnRec
>ENDIF
>RETURN m.lnRec
>
>Run once, there is little difference, but we never run things once! ;)
Mark McCasland
Midlothian, TX USA
Previous
Reply
Map
View

Click here to load this message in the networking platform