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!

EOF encounter help

Status
Not open for further replies.

Brenton

Technical User
Jul 29, 2002
43
US
I am searching through a table looking for jobs that match my discription, and I keep getting a End of file encounter error when I use skip. How can I get around this?

workcenter = thisform.text1.Value

SELECT 1
USE c:\vista\c11a
SELECT 2
USE c:\vista\jjops
SELECT 1
DO WHILE ! EOF(1)
wrkce = loc
wrkname = name
SELECT 2
LOCATE FOR jadesc=wrkname AND jawrkc=wrkce
SKIP
IF jadesc=wrkname
nseq=jaseq
nwrkc=jawrkc
SELECT 1
replace nxtseq WITH nseq
replace nextwkc WITH nwrkc
ELSE
SELECT 1
ENDIF
SKIP

ENDDO
brow
 
When you SELECT 2 and do a LOCATION, you'll be at EOF() if a match isn't found. You should check for EOF() before doing a SKIP.


-BP (Barbara Peisch)
 
Your getting the EOF error because your at the end of the recordset and the next skip tries to go beyond the end of the table. Put in some code to detect the EOF and do a skip -1 to put you at the end of the table.

It also means that your locate has gone thru the entire table and has not found any more records that meet the search criteria.
 
Brenton

Select 1
Use c:\vista\c11a in 0
Select 2
Use c:\vista\jjops in 0
Select 1
Do While ! Eof(1)
wrkce = loc
wrkname = Name
Select 2
Locate For jadesc=wrkname And jawrkc=wrkce
Skip
If jadesc=wrkname
nseq=jaseq
nwrkc=jawrkc
Select 1
Replace nxtseq With nseq
Replace nextwkc With nwrkc
Else
Select 1
ENDIF
SELECT 1
Skip
Enddo
Brow


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Try this instead:

USE "c:\vista\c11a.dbf" IN 0
USE "c:\vista\jjops.dbf" IN 0
SELECT "c11a"
SCAN ALL
wrkce = loc
wrkname = NAME
SELECT "jjops"
LOCATE FOR jadesc=wrkname AND jawrkc=wrkce
SKIP
IF jadesc=wrkname
nseq=jaseq
nwrkc=jawrkc
REPLACE nxtseq WITH nseq IN "c11a"
REPLACE nextwkc WITH nwrkc IN "c11a"
ENDIF
ENDSCAN
BROWSE


Slighthaze = NULL
[sub]craig1442@mchsi.com[/sub][sup]
"Whom computers would destroy, they must first drive mad." - Anon​
[/sup]
 
BPeisch makes a good point (i didn't see her post when i posted before so try this instead or the instead [smile]

USE "c:\vista\c11a.dbf" IN 0
USE "c:\vista\jjops.dbf" IN 0
SELECT "c11a"
SCAN ALL
wrkce = loc
wrkname = NAME
SELECT "jjops"
LOCATE FOR jadesc=wrkname AND jawrkc=wrkce
IF FOUND("jjops") && or !EOF("jjops")
SKIP
IF jadesc=wrkname
nseq=jaseq
nwrkc=jawrkc
REPLACE nxtseq WITH nseq IN "c11a"
REPLACE nextwkc WITH nwrkc IN "c11a"
ENDIF
ENDIF
ENDSCAN
BROWSE


Slighthaze = NULL
[sub]craig1442@mchsi.com[/sub][sup]
"Whom computers would destroy, they must first drive mad." - Anon​
[/sup]
 
I really don't know why any of these aren't working for me. When I run slighthaze code my status bar reads End of locate scope. What exactly does this mean? Am I missing something here? I have tried all of these examples with no success.

All your help is appreciated

 
Brenton,

The following is from the post BPeisch made earlier in this thread:

When you SELECT 2 and do a LOCATION, you'll be at EOF() if a match isn't found.

Slighthaze = NULL
[sub]craig1442@mchsi.com[/sub][sup]
"Whom computers would destroy, they must first drive mad." - Anon​
[/sup]
 
I guess I am not following. When I select 2 i am doing a locate for. What are you suggesting?

Please bare with me I am fairly new to Foxpro

 
We are suggesting that there aren't any records in jjops that have jadesc=wrkname AND jawrkc=wrkce and so the record pointer in jjops goes to the End-of-File (past the last record in jjops). Also it should be noted that the SKIP inside the SCAN...ENDSCAN loop is moving the record pointer one position DOWN further in the file. So, if you LOCATE and nothing is found the record pointer is setting on the EOF of jjops and then if you SKIP the record pointer tries to move down one more in jjops, but there isn't any more, so it throws an error in your original code. That is why I added IF FOUND() right after your LOCATE.

The message in your status bar saying "End of locate scope" is the standard VFP message when you do a locate and no matches are found. If you don't want that message to appear you can shut off the status bar:

SET STATUS BAR OFF

...or you can change it really quick right after the locate with your own custom message:

SET MESSAGE TO "Sorry that didn't match any of the records"



Slighthaze = NULL
[sub]craig1442@mchsi.com[/sub][sup]
"Whom computers would destroy, they must first drive mad." - Anon​
[/sup]
 
I failed to mention that you can also:

SET TALK OFF

if you want the Status Bar but don't want to see the VFP standard messages (command results).

Slighthaze = NULL
[sub]craig1442@mchsi.com[/sub][sup]
"Whom computers would destroy, they must first drive mad." - Anon​
[/sup]
 
OK I now understand, and I found an error in my code. I have a form with a textbox, combobox, and a command button.
When I click on the command button I want to find all records with matching descriptions(Combobox) and matching locations(textbox) from the 2 tables and put them into one table. How would I do this?

Any help is appreciated
 
There are probably a few ways to handle this.

1. Select all records from table 1 where desc = combo value and where table2 has a matching key and loc = txtbox

* think this concept will work

lcCombo = THISFORM.cboMyCombo.VALUE
lcText = THISFORM.txtMyText.VALUE
SELECT table1.keyitem, table1.desc, table2.location FROM table1 WHERE ;
table1.desc = lcCombo AND IN (SELECT keyitem FROM table2 WHERE table2.lcText = table2.location)

* you may need to add an alltrim() to the conditions depending on their size and your EXACT setting.



Jim Osieczonek
Delta Business Group, LLC
 
That will get me rolling in the right direction. Thanks to all that helped.

Brenton Pryer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top