Microsoft KB Archive/42858
Article ID: 42858
Article Last Modified on 11/21/2006
- Microsoft QuickBasic 4.0
- Microsoft QuickBASIC 4.0b
- Microsoft QuickBasic 4.5 for MS-DOS
- Microsoft BASIC Compiler 6.0
- Microsoft BASIC Compiler 6.0b
This article was previously published under Q42858
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.
Additional query words: QuickBas BasicCom