Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why is SEEK command showing error?
Message
From
08/09/2004 05:10:16
 
 
To
07/09/2004 14:39:28
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00939863
Message ID:
00940209
Views:
20

In order to use SEEK(), you have to set the index order first anyway; so you can set the index DESC and achieve the same result as SEEK with descending order.

Alan

>The differences:
>- With SEEK you can search with descending order ( for found the bottom ),
>SEEK() have not this possibility.


When I write SEEK() have not this possibility,
i want say that with SEEK you can do a SEEK in DESCENDING
( respect to the order, not respect to the data ) for any open index.

A simple example ( it is simple extend it to multiple fields ):
CLEAR
CREATE CURSOR pippo ( cc C(2))

INDEX ON cc TAG singleTag

* First char of CC is a group marker, second is a subgroup marker
SET MULTILOCK ON
=CURSORSETPROP("Buffering",5)
INSERT INTO pippo VALUES ('A2')
INSERT INTO pippo VALUES ('A1')
INSERT INTO pippo VALUES ('A3')
INSERT INTO pippo VALUES ('C2')
INSERT INTO pippo VALUES ('C1')
INSERT INTO pippo VALUES ('C5')
INSERT INTO pippo VALUES ('C4')
INSERT INTO pippo VALUES ('B5')
INSERT INTO pippo VALUES ('B2')
INSERT INTO pippo VALUES ('B1')
INSERT INTO pippo VALUES ('B7')
INSERT INTO pippo VALUES ('B6')

* You want extract the big subgroup for any group, in group ascending order:
* A3
* B7
* C5

* With SEEK you can implement a very fast solution,

SELECT pippo
SET ORDER TO singleTag
SET NEAR ON
SCAN	&& you want go to the last item of LEFT(cc,1) group
	SEEK LEFT(cc,1)+CHR(255) ORDER singleTag DESCENDING
	? CC
ENDSCAN
SET NEAR OFF
The only other solution, without use SEEK DESC, have to scan all records.

Fabio
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform