Q42858: OPEN "A:NUL" Activates Device Specified; "A:\DEV\NUL" Doesn’t
Article: Q42858
Product(s): See article
Version(s): 4.00 4.00b 4.50
Operating System(s): MS-DOS
Keyword(s): ENDUSER | SR# S890320-38 B_BasicCom | mspl13_basic
Last Modified: 16-DEC-1989
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.
THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.
Copyright Microsoft Corporation 1986-2002.