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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

End of File Encountered ERROR

Status
Not open for further replies.

stlrain95

Programmer
Sep 21, 2001
224
US
IN the following code I am getting the above error because of the SKIP command. But when I comment out. I get into an endless loop. How do I fix? When I do the same set of code earlier on a different table, I don't get this error.

Select 1
Use SHELF_DATE_TOTAL
Select 2
Use D:\FAIL_RPT\SHELF_tot_out
*Keep from data overflow
REPLACE FAIL_PCT WITH 0 FOR !EOF()
Select 2
Go TOP
Scan
Select 2
Locate FOR ship_date=A->DATE_rec
If FOUND()
Replace FAIL_QTY WITH A->qty
Replace REP_QTY WITH A->REP_QTY
If qty>0
Replace FAIL_PCT WITH FAIL_QTY/qty
Endif >0
Endif
Select 1
****This is having a problem why??
**Skip
Endscan
 
You're not getting it in the other table because it has an even number of records in it. The one that DOES crash has an odd number of records in it.

As I mentioned in your other thread, you need to remove the SKIP from the code. The SCAN..ENDSCAN loop automatically moves to the next record. SKIP causes it to move AGAIN.
 
But when I remove it it goes into a neverending loop!!
 
Ahh...there is another problem I see.

Which table are you trying to loop through...1 or 2?

At the top of the scan, you are in table 2. But at the end of the loop, you have table 1 selected. Whichever table you want to count through should be the one selected in both places.
 
I changed it to 2 and am now sitting in a continuous loop as well? This is getting very frustrating. Should I just ignore the error, when I do I can finish the program?
 
SCAN/ENDSCAN automatically SELECTs the file that was SELECTed when starting the SCAN/ENDSCAN structure. LOCATE FOR always starts at BOF(). When you start the scan, you have table 2 selected, which starts at BOF(), then you do a locate in table 2, which also starts at BOF(), so you are effectively resuming the SCAN from whatever record the record pointer is positioned at from the LOCATE, which is the same record every time since you are not moving through table 1. Also, I prefer to use alias names instead of 'A', 'B' or '1', '2' to reference tables as it is more readable.

Try this:

Select 1
Use SHELF_DATE_TOTAL
Select 2
Use D:\FAIL_RPT\SHELF_tot_out
*Keep from data overflow
REPLACE FAIL_PCT WITH 0 FOR !EOF()
Select SHELF_DATE_TOTAL
Scan
Select SHELF_tot_out
Locate FOR ship_date = SHELF_DATE_TOTAL->DATE_rec
If FOUND()
Replace FAIL_QTY WITH SHELF_DATE_TOTAL->qty
Replace REP_QTY WITH SHELF_DATE_TOTAL->REP_QTY
If qty > 0
Replace FAIL_PCT WITH FAIL_QTY/qty
Endif >0
Endif
Select 1 &&... not really necessary but more readable
Endscan

Dave S.

 
SCAN/ENDSCAN automatically SELECTs the file that was SELECTed when starting the SCAN/ENDSCAN structure. LOCATE FOR always starts at BOF(). When you start the scan, you have table 2 selected, which starts at BOF(), then you do a locate in table 2, which also starts at BOF(), so you are effectively resuming the SCAN from whatever record the record pointer is positioned at from the LOCATE, which is the same record every time since you are not moving through table 1. Also, I prefer to use alias names instead of 'A', 'B' or '1', '2' to reference tables as it is more readable.

Try this:

Select 1
Use SHELF_DATE_TOTAL
Select 2
Use D:\FAIL_RPT\SHELF_tot_out
*Keep from data overflow
REPLACE FAIL_PCT WITH 0 FOR !EOF()
Select SHELF_DATE_TOTAL
Scan
Select SHELF_tot_out
Locate FOR ship_date = SHELF_DATE_TOTAL->DATE_rec
If FOUND()
Replace FAIL_QTY WITH SHELF_DATE_TOTAL->qty
Replace REP_QTY WITH SHELF_DATE_TOTAL->REP_QTY
If qty > 0
Replace FAIL_PCT WITH FAIL_QTY/qty
Endif >0
Endif
Select SHELF_DATE_TOTAL &&... not really necessary but more readable
Endscan

Dave S.

ps. If this posted twice I apologize, I had a problem but please note the minor change in red.
 
Ugh...ok, this time I'm going to actually look at the WHOLE CODE before answering.

The other problem you've got is the LOCATE FOR in the middle of a SCAN. This moves the record pointer so it will NEVER reach the end unless the LOCATE fails. If I'm reading your code right, you want to execute this code on each record that ship_date=A->rec_date. If so, then change the loop code to this:
Code:
SELECT 2
Scan FOR ship_date=A->DATE_rec
    Replace FAIL_QTY WITH A->qty
    Replace REP_QTY WITH A->REP_QTY
    If qty>0
        Replace FAIL_PCT WITH FAIL_QTY/qty
    Endif
Endscan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top