Table of Contents

ugBASIC User Manual

PRINT ✓

SYNTAX

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

PURPOSE

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

EXAMPLE

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

See also the following example files:

ABBREVIATION

 ?

AVAILABLE ON

ANY PROBLEM?

If you have encountered a problem using this command, if you think there is a bug or the explanation is unclear, please open an issue for this keyword on GitHub. Thank you!

POWERED BY