Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
LOCATING backwards
Message
From
25/10/2003 13:05:16
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00842157
Message ID:
00842622
Views:
17
Hi Peter

Sorry to jump in. Just to make things clear, you can NOT use locate to do this, because locate will trigger VFP to try to optimize the search, and will then by itself use the indexfile in ascending order. To get the desired result, the last matching record, you must use the following code:


USE yourfile ORDER yourindex DESCENDING
SEEK yourvariable
(or SEEK(yourvariable)

<\pre>

By the way, since this is so easy to do, there is no need to have this on the wish list. That's my opinion.

>>>can you use the locate cmd to start at end of a dbf and proceed backwards?
>>
>>You might simply skip -1 in a DO WHILE loop, until you find the record (or BOF, or the equivalent of a WHILE condition). Pressumably, this would be slower than a single command (which doesn't seem to exist).
>>
>>Since this is probably not a frequent requirement, I would evaluate each situation separately: whether it is better to use a reverse index, or write your loop.
>
>Hilmar, the reverse index exists for every already existing index. It is the keyword ASCE or DESC of the SET ORDER command.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform