EOF( ) example
The following is an event handler for a button that navigates forward through a table:
PROCEDURE nextButton_onClick
if .not. eof()
skip
endif
if eof()
msgbox("Last record", "Navigation", 64)
endif
This example demonstrates an atypical programming construct: instead of using IF and ELSE, there is an IF statement for a condition, followed by a separate IF statement for the opposite condition. In this case, it works like this: if you are already at EOF( ) you do not want to attempt to navigate forward, because that will cause an error. But if you end up at EOF( ), or if you’re already at EOF( ), then you will get a message.
Many processes require traversing the entire table. The SCAN loop is designed to visit each record automatically, but sometimes you may want to manually code a loop and check for EOF( ) to see when you are done. For an example of this, see the example for COPY TO ARRAY.