| Author |
"End of File Encountered" Message
|
|
|
| Hi. When I run the below code I get an error that says "End of File
Encountered". Can someone please let me know what I'm doing wrong? I have
the IF EOF() statement intended to exit if EOF is encountered. Please help.
Thanks.
If used("sqlresult")
Select sqlresult
Go top
Do while !eof()
IF EOF( )
EXIT
ENDIF
If !void
Sum deutchmarks for trxid = 19 to deutchmarks[44]
Endif
Skip
Enddo
| |
| Dan Freeman 2005-10-27, 8:34 am |
| The SUM command leaves you at EOF(). The next thing you do is SKIP.
The golden rule is never issue SKIP without first testing for EOF().
Dan
Mike wrote:
> Hi. When I run the below code I get an error that says "End of File
> Encountered". Can someone please let me know what I'm doing wrong?
> I have the IF EOF() statement intended to exit if EOF is encountered.
> Please help. Thanks.
>
> If used("sqlresult")
> Select sqlresult
> Go top
> Do while !eof()
> IF EOF( )
> EXIT
> ENDIF
> If !void
> Sum deutchmarks for trxid = 19 to deutchmarks[44]
> Endif
> Skip
> Enddo
| |
| Cindy Winegarden 2005-10-27, 8:34 am |
| An easier way is to use Scan...EndScan. It takes care of skipping through
the file and exiting at the end (if you haven't already exited. It also
re-selects the table when it hits the EndScan line so if you've changed
tables inside the loop you don't have to reselect the table you're scanning.
You can also put a filter on the Scan...EndScan loop.
If Used("SQLResult")
Scan For !Void
Sum DeutschMarks For TrxID = 19 To DeutscheMarks[44]
EndScan
EndIf
I'm having trouble understanding what your code is supposed to do. Unless
you've got only one record that's not Void you're summing the same thing
over and over again. I assume you cut out some of the details for the
purpose of posting this question.
--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy_winegarden@msn
.com www.cindywinegarden.com
Blog: http://spaces.msn.com/members/cindywinegarden
"Dan Freeman" <spam@microsoft.com> wrote in message
news:%234Chh0m1FHA.2884@TK2MSFTNGP09.phx.gbl...
> The SUM command leaves you at EOF(). The next thing you do is SKIP.
>
> The golden rule is never issue SKIP without first testing for EOF().
>
> Dan
>
> Mike wrote:
>
>
|
|
|
|