Microsoft KB Archive/37481

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 16:55, 18 July 2020 by 3155ffGd (talk | contribs) (importing KB archive)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Base


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 "###.##"; 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 "Microsoft Basic 7.0: Basic Language Reference" for Microsoft Basic PDS versions 7.00 and 7.10
  2. Page 335 of the "Microsoft QuickBasic 4.0: Basic Language Reference" for QuickBasic 4.00 and 4.00b
  3. Page 287 of the "Microsoft QuickBasic: Basic Language Reference" for QuickBasic 4.50
  4. Page 335 of the "Microsoft Basic Compiler 6.0: Basic Language Reference" 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 "a" and "b" for the comma:

   a=3.45
   b=5.23
   PRINT USING "##.##";a,b
                

The output is as follows:

   3.45 5.23
                


Additional query words: QuickBas BasicCom

Keywords: KB37481