Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BOF() and EOF() misreporting

Status
Not open for further replies.

jerrytvspec

Technical User
Dec 1, 2001
15
US
When I open a dbf file and type '? bof()' it reports .f. Type 'go top' and it still reports .f. Type 'skip-1' and it doesn't give me an error and stays on record 1 but now 'BOF() reports .t. It didn't use to do this for my programs have been working for over two years and now all of a sudden they are bombing because of this. What switch got hit? EOF() is the same way. Type 'go bott' and it goes to the last record but reports .f. to eof() until I type 'skip'. Then it still stays on the last record but reports .t. to EOF(). Make any sense?
 
HI

"When I open a dbf file and type '? bof()' it reports .f."
[COLOR=/blue]
This is correct. Since the record pointer is located at the first record. This is not BOF()
[COLOR=/]
Type 'go top' and it still reports .f.
[COLOR=/blue]
This is correct. Since the record pointer is located at the first record. This is not BOF()
[COLOR=/]
Type 'skip-1' and it doesn't give me an error and stays on record 1 but now 'BOF() reports .t.
[COLOR=/blue]
This is correct. Since the record pointer is now before the first record. This is BOF(). But if you browse.. pointer gets to record number 1.
[COLOR=/]
EOF() is the same way. Type 'go bott' and it goes to the last record but reports .f. to eof() until I type 'skip'. Then it still stays on the last record but reports .t. to EOF().
[COLOR=/blue]
This is also correct. Since the record pointer is now at the last record. This is EOF(). When you skip and go past the last record EOF() becomes .t..

These are always the facts. Nothing wrong with FP behaviour.
[COLOR=/]


Make any sense? ramani :-9
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Hi,

To extend the concept, you have to consider BOF and EOF as "suplemental" records. It means that you have a record (BOF) before the first record and another one (EOF) after the last one.

So BOF is located going TOP and issuing SKIP -1 and EOF going BOTTOM and issuing SKIP. The only thing that may introduce error is when taking decisions on RECNO() is the fact (as Ramani explains) that this function only returns values related to "actual" records.

David.

 
Thanks for your responce. Maybe I didn't totally explain the whole problem correctly. I wrote these programs over a year ago and they have been working OK. Then all of a sudden they started messing up. I think I better understand the eof() and bof() command better but I'm still get errors in the program and have found something else also. When I search a file either by 'locate' or 'seek' for something that doesn't exist I should get a eof(), right? I don't.
 
Jerry,
These results can be affected by SET COMPATIBLE, SET EXACT, SET NEAR, SET ANSI and probably some others. Check to see if your program explicitly SETs these values. Some of these values can be different depending on whether you are running in the developer's mode or runtime, and can be overriden by a CONFIG.FP file. (Sometimes you don't plan on using one, but due to FPs checking it may "find" one and use it any way. It's a good idea to have your program display the value of SYS(2019) some where, so you can check it's current value.)

Rick
 
Hi
If you have SET NEAR ON
SEEK LOCATE etc locates the record pointer to the nearest record, not necessarily EXACT match. IF SET NEAR OFF.. then EOF() will be reached, if matching record are not available. SO somewhere, you might have added these codes. These SET commands scope to the entire application, even if it is used in some part of your application. SO these SET commands hall be used in the main.prg and elsewhere, you should change and then put that back to same status. This way you will get a good control over the software.
:)
ramani :-9
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top