OPEN "A: NUL" Activates Device Specified; "A:\DEV\NUL" Doesn't (42858)



The information in this article applies to:

  • Microsoft QuickBASIC 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBASIC 4.5
  • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0
  • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0b

This article was previously published under Q42858

SUMMARY

QuickBasic allows you to OPEN the file "NUL" for INPUT or OUTPUT. When CLOSEd, this temporary file loses all information that was written to it. Even though a FILE is not actually created, the device specified in the OPEN statement is activated. The following example will activate the "A:" drive:
   OPEN "A:NUL" FOR OUTPUT AS #1
				
If the device is not ready, a "Device Not Ready" error is generated. To prevent the device from being activated, the MS-DOS prefix "\DEV" must be included. The following OPEN statement will not activate the "A:" drive:
   OPEN "A:\DEV\NUL" FOR OUTPUT AS #1
				
This information applies to QuickBasic Versions 4.00, 4.00b, and 4.50 and to Microsoft Basic Compiler Versions 6.00 and 6.00b.

Under Microsoft Basic PDS Version 7.00, you cannot prevent the named device from being activated with the "\DEV" prefix. Both the above statements result in a "Disk not ready" error message from either a compiled program or one run under the QBX.EXE environment. The error can still be trapped using normal Basic error handling, however.

Modification Type:MinorLast Reviewed:1/9/2003
Keywords:KB42858