Q(uick)BASIC Statement: RESET
Quick View
RESET
A file I/O statement that closes all disk files
Worth knowing
Useful and cross-version information about the programming environments of QBasic and QuickBasic.
Syntax
- RESET
Description/Parameter(s)
The RESET statement closes all open disk files and writes data still in the file buffers to disk.
All files must be closed before a disk is removed from its drive.
See also:
Syntax
- RESET
Description/Parameter(s)
- RESET closes all open disk files and writes data still in the file buffers to disk.
Example
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
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
See also: