Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
EOF Function Example
◄Example► ◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
' The example below uses the INPUT statement to receive input from the user
' and the EOF function to test for the end-of-file condition which will
' cause the program to end.
' To try this example:
' 1. Choose New Project from the File menu
' 2. Copy the code example below to the code window
' 3. Press F5 to run the example
CLS ' Clear the screen
OPEN "LIST" FOR OUTPUT AS #1
DO
INPUT " NAME: ", Name$ ' Read entries from the keyboard
INPUT " AGE: ", Age$
WRITE #1, Name$, Age$
INPUT "Add another entry"; R$
LOOP WHILE UCASE$(R$) = "Y"
CLOSE #1
OPEN "LIST" FOR INPUT AS #1 ' Echo the file back
CLS ' Clear the screen
PRINT "Entries in file:": PRINT
DO WHILE NOT EOF(1)
LINE INPUT #1, REC$ ' Read entries from the file
PRINT REC$ ' Print the entries on the screen
LOOP
CLOSE #1
KILL "LIST"