Microsoft KB Archive/34610

= WRITE# Statement Works with Semicolon Despite BC.EXE Error =

Article ID: 34610

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
 * Microsoft BASIC Professional Development System 7.0

-



This article was previously published under Q34610



SUMMARY
Microsoft does not recommend linking object modules that produced one or more severe error messages at compile time. The behavior of such programs cannot be guaranteed to work in future product versions, or even to work at all.

An example is shown below for the case of improperly using a WRITE# statement with a trailing semicolon with the intent to suppress a carriage return. PRINT# is intended for this purpose, not WRITE#.



MORE INFORMATION
According to Page 455 of the &quot;Microsoft QuickBasic 4.0: Basic Language Reference&quot; manual for QuickBasic Versions 4.00 and 4.00b, the WRITE# statement should not allow a semicolon at the end of its arguments. QB.EXE correctly displays an &quot;Expected:Expression&quot; error message on the WRITE# statement at run time. A &quot;Syntax Error&quot; is correctly produced when the BC.EXE compiler tries to compile the following program, which has a semicolon at the end of a WRITE statement: open &quot;data&quot; for output as #1 write #1, str$(5);   ' This line is not allowed to have a &quot;;&quot; write #1, str$(5) close #1 Despite the &quot;severe&quot; error message at compile time, BC.EXE produces an object module that can be linked into an executable program. This program executes as you might expect a WRITE# with a semicolon at the end to work (i.e., no carriage return or linefeed). However, this behavior cannot be guaranteed for future versions.

Note that the PRINT# statement can be used in place of the WRITE# statement if you wish to use a trailing semicolon to suppress the carriage return, as shown in the following program: open &quot;data&quot; for output as #1 PRINT#1, CHR$(34) + STR$(5) + CHR$(34) + &quot;, &quot;;   'This is allowed. write #1, str$(5) close #1 The WRITE# statement delimits output arguments with commas, and also places double quotation marks around string arguments.

Additional query words: QuickBas BasicCom

Keywords: KB34610

-

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

© Microsoft Corporation. All rights reserved.