Chapter
10
I
BASIC
Keywords
PRINT
USING
Statement
PRINT USING
format;
data[,data,
...
I
Prints data using
a
format you specified. This statement is espe-
cially useful for printing report headings, accounting reports,
checks,
or
any other documents that require
a
specific format.
Format
consists
of
1
or
more field specifierb), or any alphanu-
meric character.
Format
must be enclosed in quotation marks.
Data
may be string and/or numeric value(s1. If you specify more
than
1
data item in the statement, use the same separators as
described in PRINT.
With PRINT USING, you may use certain characters called field
specifiers,
to
format the field. You may use more than
1
field spe-
cifier, except
as
indicated.
Specifiers
for
String Fields:
!
prints the first character in the string only
PRINT USING
'I!";
"PERSONNEL"
BASIC prints P.
\spaces
\
prints
2
+
n
characters from the string (n is the num-
ber
of
spaces between the slashes). If you type the
backslashes without any spaces, BASIC prints
2
char-
acters; with one space, BASIC prints
3
characters, and
so
on. If the string is longer than the field, the extra
characters are ignored. If the field is longer than the
string, the string is left-justified and padded with
spaces on the right.
PRINT USING
"\BBB\";
"PERSONNEL"
BASIC prints PERSO
prints the string without modifications.
10
A$="TAKE":B$="RACE"
20
PRINT USING
"!";A$;
30
PRINT USING
"&";E$
When this program is run, BASIC prints TRACE.
&
272