bas7ex.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.
ERDEV, ERDEV$ Function Programming Example
                       Example                 Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
'This example prints the values of ERDEV and ERDEV$ after the program
'generates an error attempting to open a text file.
 
DEFINT A-Z
 
'Indicate first line of error handler.
ON ERROR GOTO ErrorHandler
 
'Attempt to open the file.
OPEN "A:JUNK.DAT" FOR INPUT AS #1
 
END
 
'Error handling routine.
'Prints values of ERDEV and ERDEV$ and returns error control to BASIC.
ErrorHandler:
PRINT "ERDEV value is "; ERDEV
PRINT "Device name is "; ERDEV$
ON ERROR GOTO 0
 
'Sample Output
'
'Running the program with drive A unlatched produces the following
'output (2 is the DOS error code for "Drive not ready"):
'
'ERDEV value is  2
'Device name is A: