Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Recno funny
Message
From
30/07/2007 12:56:55
 
 
To
30/07/2007 10:41:10
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Vista
Miscellaneous
Thread ID:
01244570
Message ID:
01244643
Views:
12
>A RECNO() funny - If you have a table and you do a locate (or skip etc) and end up at EOF() then RECNO() returns 1 more than the actual number of records. Does everyone but me know about this :)

A different funny happens with BOF(). When you are at BOF() there is no phantom record. You are actually pointed to the first record in the table -- using the active index.
CREATE CURSOR temp (f1 c(10))
INSERT INTO temp VALUES ("bbb")
INSERT INTO temp VALUES ("ccc")
INSERT INTO temp VALUES ("aaa")
INDEX ON f1 TAG f1
GO top
SKIP -1
? BOF() -------------------------->  .T.
? RECNO() ------------------------>  3
REPLACE f1 WITH "xxx"
? f1 -----------------------------> "xxx"
? BOF() --------------------------> .F.
? RECNO() ------------------------> 3
Granted I have almost never worked with BOF() but it took me a while to discover why
LOCATE FOR somecondtion
SKIP -1
IF BOF()  && Am I at top of file -- yup
  SKIP    && thought I was going to top of file but was actually going to 2nd record
ENDIF
didn't work properly
Previous
Reply
Map
View

Click here to load this message in the networking platform