Microsoft KB Archive/61345

= Differences Between FormatX$ Functions & PRINT USING Statement =

Article ID: 61345

Article Last Modified on 11/21/2006



This article was previously published under Q61345



SUMMARY
This article demonstrates the differences between the FormatX$ Add-On-Library (DTFMTxx.LIB) functions and the Basic PRINT USING statement, specifically in the case of the &quot;#&quot; character.

This information applies to Microsoft Basic Professional Development System (PDS) versions 7.00 and 7.10 for MS-DOS and MS OS/2. FormatX$ refers to the Add-On-Library functions FormatI$, FormatL$, FormatS$, FormatD$, and FormatC$ found in Basic PDS 7.00 and 7.10.

In the PRINT USING statement, the # sign is used in the string identifier to specify a digit placeholder. If there isn't a digit in that location, a space is put in its place. In the FormatX$ functions, the # is also a placeholder. However, if there isn't a digit, the location is not padded with a space.



MORE INFORMATION
The FormatX$ functions can be invoked from within the QB.EXE environment by installing the DTFMTER.QLB Quick library. These functions can be invoked from .EXE programs by linking in the appropriate DTFMTxx.LIB library.

The FUNCTION declarations necessary for the FormatX$ functions are contained in the FORMAT.BI include file, which can be included in your source file as follows: REM $INCLUDE:'FORMAT.BI' The syntax for the FormatX$ function(s) is as follows FORMATx$ (Variable, fmt$) where:

  &quot;x&quot; is the first letter of the data type being manipulated:      Data Type           Syntax -          --

Integer            FORMATI$ Long integer       FORMATL$ Single precision   FORMATS$ Double precision   FORMATD$ Currency           FORMATC$  &quot;Variable&quot; is the variable to be manipulated. &quot;fmt$&quot; is a string expression defining the output format.

The format for the PRINT USING statement is as follows PRINT USING fmt$; Variable [,Variable2...][,|;] where:


 * 1) &quot;fmt$&quot; is a string expression defining the output format.
 * 2) &quot;Variable&quot; is an expression(s) to be manipulated.
 * 3) &quot;,&quot; or &quot;;&quot; are optional output choices to print next output immediately following. (Note that PRINT USING does not support &quot;print zones.&quot;)

The following code example demonstrates the difference in the # operand in the fmt$ argument for FORMATX$ versus PRINT USING: ' $INCLUDE: 'FORMAT.BI' A = 123.456 B = 88.99

' -- PRINT USING STATEMENTS: PRINT USING &quot;#####.##&quot;;A PRINT USING &quot;######.###&quot;;B PRINT

' -- FORMATX$ STATEMENTS: PRINT FORMATS$(A,&quot;#####.##&quot;) PRINT FORMATS$(B,&quot;######.###&quot;;B  END The output will resemble the following:      123.46       88.990

123.46  88.99

Additional query words: BasicCom

Keywords: KB61345

-

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

© Microsoft Corporation. All rights reserved.