``

prev Menu next

PRINT USING ☆☆
PRINT USING
`PRINT USING format_string : numeric_expression`
Displays the value of the expression using the format.
(1) The form without a exponent part
Example.
`PRINT USING "----%.####": a`
displays the value of a with the integer places including the sign 5 digits, fractional places 4 digits.

                "   12.5000" for a= 12.5
                "  -12.5000" for a=-12.5
                "    0.0000" for a=    0

Usage
(i) Integer part.
Put a queue of an arbitrary number of either of `+`'s or `-`'s,
without a break put a queue of an arbitrary number of either of %'s or #'s.
Meanings
`-` Replaced by numerals, a minus sign, or spaces.
`+` Replaced by numerals, a sign, or spaces.
% Replaced by numerals.
# Replaced by numerals or spaces.
(ii) Fractional part
Put a queue of an arbitrary number of #'s.
(Note) A format for a negative number must have `+`'s or `-`'s.
(Note) If Option menu - compatibility - behavior - "No preceding space generated" is checked, # can be replaced by a minus sign, that is, a format consisting of only #'s can be used for a negative number.
(2) The form with a exponent part
Example.
`PRINT USING "-%.#####^^^^":a`
displays the value of a with the sign part 1 digit, the integer part 1 digit, the fractional part 5 digits, and exponent part 4 digits.

                " 1.25000E+01" for a= 12.5
                "-1.25000E+01" for a=-12.5
                " 0.00000E+00" for a=    0

Usage
(i) Integer part and fractional part
Same as the form without an exponent part.
(ii) Exponent part
At least 3 ^'s shows the exponent part (including "E").
Notes
1. A format string is a string expression, which can contain string variables or string functions.
Example
`PRINT USING "." & REPEAT$("#",15) : 1/7`
2. A format string can contain two or more formats.
Example.
`PRINT USING "### #.############": n, 1/n`
On this case, the expressions must be punctuated by commas (not semicolons).
3. A format item can contain commas.
Example
`PRINT USING "###,###,###,###,###": 2^32`
Output 4,294,967,296
Note that commas are part of a format item.
4. When a format string contains non-format characters, they act as punctuations of format items and are outputted just like they are.
Example
`PRINT USING "A= ### B= ###": A, B`
(Note) The format characters are the following 11 characters.
# $ % * + , - . < > ^

5. Formatting can be used for strings.
Example
`PRINT USING "<#####": s$`
Usage
(1) The first character of a format can be a "<" or a ">"
"<" left adjusts a string. ">" right adjusts a string.
Lack of "<" or ">" center adjusts.
(2) "<" or ">" is part of digits.

6. The format string can be assigned by a IMAGE line.
Example

    50 IMAGE: #####   #.#########
    60 PRINT USING 50: N, 1/N

Refer to USING$ function Non-fatal exceptions
(Note) The above is not the whole. For more information, see the ANSI Standard Full BASIC, JIS Full BASIC or ECMA BASIC standard.