Microsoft KB Archive/42858

= OPEN &quot;A: NUL&quot; Activates Device Specified; &quot;A:\DEV\NUL&quot; Doesn't =

Article ID: 42858

Article Last Modified on 11/21/2006

-

APPLIES TO


 * 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



SUMMARY
QuickBasic allows you to OPEN the file &quot;NUL&quot; 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 &quot;A:&quot; drive: OPEN &quot;A:NUL&quot; FOR OUTPUT AS #1 If the device is not ready, a &quot;Device Not Ready&quot; error is generated. To prevent the device from being activated, the MS-DOS prefix &quot;\DEV&quot; must be included. The following OPEN statement will not activate the &quot;A:&quot; drive: OPEN &quot;A:\DEV\NUL&quot; 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 &quot;\DEV&quot; prefix. Both the above statements result in a &quot;Disk not ready&quot; 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

Keywords: KB42858

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.