Available on: all targets
✓ verified

PRINT

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 decription 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).

SYNTAX

 PRINT [expr] [; [expr] [; ...] ... ]
 PRINT [expr] [, [expr] [, ...] ... ]
 PRINT @expr, [, [expr] [, ...] ... ]


Legend
  • id : identifier
  • type : datatype
  • v : value
  • "..." : string
  • [...] : optional

EXAMPLE

 PRINT "HELLO WORLD!"
 PRINT (a + b);" IS A SUM!";
 PRINT @100, "HELLO WORLD!"


Used in:

ABBREVIATION: ?

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:

  • PUR-120 - A game in 10 lines of max 120 characters (w/abbrev.)
  • EXTREME-256 - A game in 10 lines of max 256 characters (w/abbrev.)
  • SCHAU - Any program in 10 lines of max 256 characters (w/abbrev.)
In order to reduce space you can use this abbreviation for this instruction:

PRINT ↔ ?

Any problem?

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