Microsoft KB Archive/37481

= PRINT USING Statement Fails to Use Print Zones =

Article ID: 37481

Article Last Modified on 11/21/2006



This article was previously published under Q37481



SUMMARY
The PRINT USING statement is not designed to print the values of an expression list in the 14-character print zones. Instead, it ignores the comma and treats it like a semicolon. In QuickBasic version 4.50, the syntax checker correctly changes the comma to a semicolon. However, several manuals (listed below) and the online help system incorrectly state that the comma is syntactically legal.



MORE INFORMATION
To work around this restriction of PRINT USING and to allow printing at the next print zone (at every 14th character), you can do the following: end the PRINT USING statement with a semicolon, then follow with a PRINT statement that just has a comma as an argument, and then PRINT the next item desired to be in the next print zone. For example: x = 33.45 PRINT USING &quot;###.##&quot;; x;   ' Prints x, keeping cursor on same line. PRINT,                ' Moves cursor to next print zone on same line. PRINT x   ' x prints on same line at column 14, the next print zone.

Documentation Errors
The incorrect syntax for the PRINT USING statement is as follows: PRINT USING formatstring; expressionlist [{,|;}] The incorrect definition for the PRINT USING statement is as follows:

The position of each printed item is determined by the punctuation used to separate the items in the list. Basic divides the line into print zones of 14 spaces each. In the expression list, a comma makes the next value print at the start of the next zone. A semicolon makes the next value print immediately after the last value.

This incorrect syntax or definition is given in each of the following references:


 * 1) Page 275 of the &quot;Microsoft Basic 7.0: Basic Language Reference&quot; for Microsoft Basic PDS versions 7.00 and 7.10
 * 2) Page 335 of the &quot;Microsoft QuickBasic 4.0: Basic Language Reference&quot; for QuickBasic 4.00 and 4.00b
 * 3) Page 287 of the &quot;Microsoft QuickBasic: Basic Language Reference&quot; for QuickBasic 4.50
 * 4) Page 335 of the &quot;Microsoft Basic Compiler 6.0: Basic Language Reference&quot; for Microsoft Basic Compiler versions 6.00 and 6.00b
 * 5) The online help system for Microsoft QuickBasic 4.50 under the entry for PRINT USING statement
 * 6) The online help system for Basic PDS 7.00 under the entry for the PRINT USING statement

The following is a code example that demonstrates that PRINT USING treats commas as if they were semicolons. When run in the QB.EXE or QBX.EXE environment, the code example will correctly and automatically substitute a semicolon between the variables &quot;a&quot; and &quot;b&quot; for the comma: a=3.45 b=5.23 PRINT USING &quot;##.##&quot;;a,b The output is as follows:   3.45 5.23

Additional query words: QuickBas BasicCom

Keywords: KB37481

-

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

© Microsoft Corporation. All rights reserved.