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.
Article Q57368
◄Contents► ◄Index► ◄Back►
─────────────────────────────────────────────────────────────────────────────
◄Knowledge Base Contents► ◄Knowledge Base Index►
Explanation of MS-DOS Critical Error Codes Returned by ERDEV - Q57368
ERDEV is an integer function that returns an error code from the last
device to declare a critical error. ERDEV is set by the critical error
handler, Interrupt 24h, when MS-DOS detects a critical MS-DOS call
error.
For block and character device errors, ERDEV will contain the error
code from Interrupt 24h in the lower 8 bits. For block devices only,
bit positions 9 to 16 contain device-attribute information which is
found in the device-driver header of the device that the error is
coming from.
The information in this article applies to:
- The Standard and Professional Editions of Microsoft Visual Basic
version 1.0 for MS-DOS
- Microsoft GW-BASIC versions 3.2, 3.22 and 3.23 for MS-DOS
- Microsoft QuickBasic versions 2.0, 2.01, 3.0 4.0, 4.0b, and 4.5 for
MS-DOS
- Microsoft Basic Professional Development System (PDS) versions 7.0
and 7.1 for MS-DOS
- Microsoft Basic Compiler versions 6.0 and 6.0b for MS-DOS
When using Microsoft Visual Basic versions 1.0 for MS-DOS, or Microsoft
Basic PDS version 7.0 or 7.1 for MS-DOS, ERDEV can also be set by a
time-out error on the communications port and indicates which option
in the OPEN COM statement (CD, CS, or DS) is experiencing the time-out.
More Information:
If ERDEV returns an error from a block device (such as a floppy disk
drive or fixed disk) or from a character device (such as a terminal or
printer), the low byte of ERDEV will return a MS-DOS error code which
is a value between 0 and 12. The following is a list of these errors:
0 write-protect error
1 unknown unit
2 drive not ready
3 unknown command
4 date error (CRC)
5 bad request structure length
6 seek error
7 unknown media type
8 sector not found
9 printer out of paper
10 write fault
11 read fault
12 general failure
13 reserved
14 reserved
15 invalid disk change (MS-DOS version 3.0 only)
For more information on MS-DOS error codes, see Interrupt 24h on
Page 481 of "Advanced MS-DOS Programming, 2nd Edition," by Ray Duncan
(Microsoft Press, 1988).
If the device returning an error is a block device, the high byte of
the integer returned by ERDEV will contain device attribute
information. This device attribute information comes from the
device-attribute word in the device header. The only bits from this
word returned by ERDEV are bits 15, 14, 13, XX, 3, 2, 1, and 0, in
that order. XX indicates that bits 12 through 4 of the
device-attribute word will always return zero. The following is a
description of the bits in the device-attribute word that are
meaningful to ERDEV:
Bit
Position Bit Significance
-------- --- ------------
8 15 0 if block device
7 14 1 if IOCTL read and write supported
6 13 1 if ROM BIOS parameter block in boot sector
should be used to determine media
characteristics
0 if media ID byte should be used
4 3 1 if current CLOCK$ device
3 2 1 if current NUL device
2 1 1 if driver supports 32-bit sector addressing
(MS-DOS version 4.0)
1 0 1 if current standard input device (stdin)
For more information on device-attribute words, see Page 264 of the
"Advanced MS-DOS Programming" Microsoft Press book.
When using Microsoft Visual Basic version 1.0 for MS-DOS, or
Microsoft Basic PDS version 7.0 or 7.1 for MS-DOS, ERDEV also returns
information for COM time-out errors in the low byte. If there is a
time-out, ERDEV is set to a value that indicates the signal line that
timed out, according to the following table:
ERDEV Value Signal Line
----------- -----------
128 Clear to Send (CTS) timeout
129 Data Set Ready (DSR) timeout
130 Data Carrier Detect (DCD) timeout
The following code fragment generates the MS-DOS and COM time-out error
codes (low byte) and device attribute information (high byte):
x= ERDEV
DosErrCode = x AND &HFF ' Low byte of ERDEV.
DevAttr = (x AND &HFF00) \56 ' High byte of ERDEV.
The following example prints the values of ERDEV after the program
tries to OPEN a read only file for OUTPUT:
Example
-------
' To try this example in VBDOS.EXE:
' 1. From the File menu, choose New Project.
' 2. Copy the code example to the Code window.
' 3. Press F5 to run the program.
DEFINT A-Z
ON ERROR GOTO ErrorHandler
OPEN "C:\heFile.DAT" FOR OUTPUT A #1 ' TheFile is a read-only
' file.
END
ErrorHandler:
x = ERDEV
DosErrCode = x AND &HFF ' Low byte of ERDEV.
PRINT "The MS-DOS error code returned by ERDEV => "; x
RESUME NEXT