Cannot Nest I/O Statements or Functions in I/O Statements (37414)
The information in this article applies to:
- Microsoft Visual Basic for MS-DOS
- 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
- Microsoft Basic Professional Development System (PDS) for MS-DOS and MS OS/2 7.0
- Microsoft Basic Professional Development System (PDS) for MS-DOS and MS OS/2 7.1
This article was previously published under Q37414 SUMMARY
With two sequential files open, #1 for INPUT and #2 for OUTPUT, the
following statement incorrectly sends output to the screen instead of
to file #2:
PRINT #2, INPUT$(10, #1)
This behavior occurs in the Standard and Professional Editions of
Microsoft Visual Basic for MS-DOS, version 1.0; in Microsoft QuickBasic
for MS-DOS, versions 4.0, 4.0b, and 4.5; in Microsoft Basic Compiler
for MS-DOS and MS OS/2, versions 6.0 and 6.0b; and in Microsoft Basic
Professional Development System (PDS) for MS-DOS and MS OS/2,
versions 7.0 and 7.1. This limitation is documented in the README.DOC
file for Microsoft Basic PDS for MS-DOS and MS OS/2, versions 7.0 and
7.1.
This information is also included with the Help file provided with
the Standard and Professional Editions of Microsoft Visual Basic
for MS-DOS, version 1.0.
To work around this behavior, put the INPUT$ function into a
temporary string variable, then PRINT that temporary string into the
second file.
The general rule to observe is as follows: do not nest input/output
(i/o) statements or functions within other i/o statements or
functions. This is a design limitation.
Modification Type: | Minor | Last Reviewed: | 8/16/2005 |
---|
Keywords: | KB37414 |
---|
|