JCrum


The docs say that when SEEK() does not find a match then the record pointer is moved to the end of the file. But if you are constantly changing what you are seeking then do you have to move the record pointer back to the top of the file manually
For example:
USE this.dbf IN 2 ALIAS this
SELECT this
INDEX ON name TAG name
USE that.dbf IN 3 ALIAS that
SELECT that
SCAN FOR name = "MYNAME"
IF SEEK(that.name, "this", "name")
do something...
ENDIF
ENDSCAN

What happens to the record pointer if scan has identified that 5 records meet the criteria and I need to find that.name in this.dbf but the first that.name was not found Does the record pointer go back to the top of the file when the next scan takes place

TIA,
Jennifer



Re: Moving the record pointer

CetinBasoz


No matter where record pointer is, another seek() would seek it from the index (from the top). In other words, you don't need to move pointer yourself anywhere.

(I'm assuming you used "this" in your code just for sampling).

Your code translates to this in pseudocode:

scan for name = "MYNAME" && since you're using a constant it'd do this scan...endscan loop N times. 5 as you say

if seek( that.Name,"this", "name" ) && if found - whatever you do there would be done 5 times with different record from that - (this is always the same found record)

* do something && if not found equivalant to an empty body scan..endscan loop

endif

endscan

PS: It could be written as:

select that

if seek( "MYNAME","this", "name" )

scan for name = "MYNAME"

* do something

endscan

endif






Re: Moving the record pointer

JCrum

Thank you!