ex.hlp (Topic list)
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.
RESET Statement Example
                        Example                Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
' This example uses the RESET statement to close several files at once. The
' program attempts to write to the previously opened files, causing an error
' and demonstrating that all files are closed.
 
 DEFINT A-Z
 ON ERROR GOTO ErrHandler          ' Set up the error handling routine
 
 CLS                               ' Clear the screen
 FOR I = 1 TO 3
     OPEN "Test" + RIGHT$(STR$(I), 1) + ".dat" FOR OUTPUT AS FREEFILE
     PRINT "File #"; I; "has been opened for output."
 NEXT I
 PRINT : PRINT "Press any key to RESET all open files."
 PRINT
 Z$ = INPUT$(1)
 RESET
 FOR I = 1 TO 3
     PRINT "Trying to write to file #"; I
     PRINT #I, "Test data"
 NEXT I
 END
 
ErrHandler:                        ' Error 52 is "Bad File Name or Number"
     IF ERR = 52 THEN PRINT "  File #"; I; "not open. RESET closed it."
     RESUME NEXT