15.5 PRINT USING Statement Error Conditions
There are two types of PRINT USING error conditions: fatal
and warning. BASIC signals a fatal error if:
.
The format string is not a valid string expression
.
There are no valid fields in the format string
.
You specify a string for a numeric field
.
You specify a number for a string field
.
You separate the items to be printed with characters
other than commas or semicolons
.
A format field contains an invalid combination of charac-
ters
.
You print a negative number in a floating-dollar sign or
asterisk-fill field without a trailing minus sign
BASIC issues a warning if a number does not fit in the field.
If a number is larger than the field allows, BASIC prints a
percent sign ( % ) followed by the number in the standard
PRINT format and continues execution.
If a string is larger than any field other than an extended
field, BASIC truncates the string and does not print the excess
characters.
If a field contains an invalid combination of characters,
BASIC does not recognize the first invalid character or any
character to its right as part of the field. These characters
may form another valid field or be considered text. If the in-
valid characters form a new valid field, a fatal error condition
may arise if the item to be printed does not match the field.
The following examples demonstrate invalid character com-
binations in numeric fields:
Example 1
PRINT USING "$$**##.##",5.41,16.30
The dollar signs form a complete field and the rest forms a
second valid field. The first number (5.41) is formatted by the
first valid field ($$). It prints as ``$5''. The second number
(16.30) is formatted by the second field (
**
##.##) and prints
as ``
**
16.30''.
Output 1
$5**16.30
Example 2
PRINT USING "##.#^^^",5.43E09
Because the field has only three carets instead of four, BASIC
prints a percent sign and the number, followed by three
carets.
Output 2
% .543E+10^^^
Example 3
PRINT USING "©LLEEE","VWXYZ"
You cannot combine two letters in one field. BASIC interprets
EEE as a string literal.
Output 3
VWXEEE
determining the error number