The PRINT
instruction displays information on the screen, starting from the current
cursor position. An item or a list of items can follow the command. If any item is omitted,
a blank line is printed. The list of items can consist of any group of strings, variables or constants.
Each element in the list must be separated by either a semi-colon ;
or a comma ,
.
A semi-colon prints the data immediately after the previous value, whereas a comma first
moves the cursor to the next TAB
position on the screen.
Normally the cursor will be advanced downwards by a single line after each PRINT
instruction. This can be suppressed by adding a separator after the print. As before, a semicolon
will preserve the cursor position after the operation, and a comma will place the
cursor to the next TAB
stop before proceeding.
All data printed to the screen is formatted by using the specific formatter for numbers,
and "as is" for strings, while complex data will be printed out with an unique self descriptive string.
For the numeric data, the numbers are always translated into decimal system. Nothing is written
if parameter is omitted.
Because the PRINT
instruction prints with mono-spaced characters, there is a correlation between
the number of characters printed and the number of columns those characters occupy. This ensures
that each character uses only one column. You can use the SPC
keyword to print after
a specific number of spaces.
It is also possible to put the output to a specific location. The PRINT @
command is used
to place output at a specified place on the screen. For this purpose the screen is divided
into a SCREEN COLUMNS
x SCREEN ROWS
grid, giving a certain amount of positions.
The expression after the @
can be a number, a variable or an arithmetic expression, as
long as the value is between 0
and ((SCREEN COLUMNS*SCREEN ROWS)-1)
.
Finally, note that the supplied string to print may contain control characters (clear
screen, move cursor, and so on), which will be interpreted by the PRINT
command.
Since some targets give meaning to these characters, it is possible to omit
this behavior by using the RAW keyword. This keyword will turn off interpretation for the
expression that follows it, and turn it back on for the next one.
PRINT [[RAW] expr] [; [[RAW]expr] [; ...] ... ] PRINT [[RAW] expr] [, [[RAW]expr] [, ...] ... ] PRINT @expr, [, [[RAW]expr] [, ...] ... ]
Join BASIC 10Liner Contest with ugBASIC!
An interesting competition is held at the beginning of each year: the
BASIC 10Liner Contest.
It is possible to use ugBASIC to participate in the next
"BASIC10Liner" competition, in the following categories:
PRINT ↔ ?
If you have found a problem with this keyword, if you think there is a bug or, more
simply, you would like it to be improved, open an issue for this example on GitHub.
Thank you!
open an issue
BACK TO KEYWORDS