15.1 Overview of the PRINT USING Statement
The ability to format data with the PRINT USING state-
ment is useful because the way in which BASIC displays
data with the PRINT statement is often limited. For exam-
ple, a program may use floating-point numbers to represent
dollars and cents. The PRINT statement displays floating-
point numbers with up to six digits of accuracy, and places
the decimal point anywhere in that 6-digit field. In contrast,
PRINT USING lets you display floating-point numbers in
the following ways:
.
Rounded to a number of specified decimal places
.
Vertically aligned on the decimal point
.
Preceded by a dollar sign
.
With commas every third digit to the left of the decimal
point
Formatting monetary values in this way provides a more
readable report. Another use for formatted numeric values
might be to print checks on a printer. PRINT USING lets
you print numbers with a dollar sign and an asterisk-filled
field preceding the first digit.
PRINT USING also formats string data. With it you can
left- and right-justify string expressions, or center a string
expression over a specified column position. Further, the
PRINT USING statement can contain string literals. These
are strings that do not control the format of a print item,
but instead are printed exactly as they appear in the format
string.
Digital recommends that you declare all format expressions
as string constants. When you do this the BASIC compiler
instructs the Run-Time Library to compile the string at
compile time rather than at run time, thus improving the
performance of your code.