QBasic 1.1: PRINT USING Statement
Explanation
PRINT USING, LPRINT USING Statements
PRINT USING writes formatted output to the screen or to a file.
LPRINT USING prints formatted output on the printer LPT1.
Worth knowing
Useful and cross-version information about the programming environments of QBasic, QuickBasic and Visual Basic for DOS.
Syntax
PRINT [#filenumber%,] USING formatstring$; expressionlist [{; | ,}] |
LPRINT USING formatstring$; expressionlist [{; | ,}] |
Description / Parameter(s)
filenumber% |
The number of an open sequential file. |
formatstring$; |
A string expression containing one or more format specifiers. |
expressionlist |
A list of one or more numeric or string expressions to print, separated by commas, semicolons, spaces, or tabs. |
{; | ,} |
Determines where the next output begins: |
|
; |
means print immediately after the last value. |
, |
means print at the start of the next print zone. |
|
Print zones are 14 characters wide. |
|
Format Specifiers: |
Characters that format a numeric expression |
# | Digit position. |
. | Decimal point position. |
, | Placed left of the decimal point, prints a comma every third digit. |
+ | Position of number sign. |
^^^^ | Prints in exponential format. |
|
- | Placed after digit, prints trailing sign for negative numbers. |
$$ | Prints leading $. |
** | Fills leading spaces with *. |
**$ | Combines ** and $$. |
|
|
Characters used to format a string expression |
& | Prints entire string. |
! | Prints only the first character of the string. |
|
\ \ | Prints first n characters, where n is the number of blanks between slashes + 2. |
|
|
Characters used to print literal characters |
_ | Prints the following formatting character as a literal. |
|
| Any character not in this table is printed as a literal |
|
|
Example
a = 123.4567
PRINT USING "###.##"; a
LPRINT USING "+###.####"; a
a$ = "ABCDEFG"
PRINT USING "!"; a$
LPRINT USING "\ \"; a$