Difference between revisions of "PRINT"

From BeebWiki
Jump to: navigation, search
(recreated)
 
m (1 revision)
 
(No difference)

Latest revision as of 19:13, 8 March 2015

PRINT is a statement that displays the values of expressions.

PRINT
Availability Present in all original versions of BBC BASIC.
Syntax BASIC I-V PRINT {;|,|'|~|SPC <numeric>|TAB(<numeric>[,<numeric>])|<string>|<numeric>}
Token (hex) BASIC I-V F1 (statement)
Description BASIC I-V Prints strings and numeric values converted to strings, with formatting characters, to the OSWRCH output stream.
Associated keywords @%, COUNT, INPUT, SPC, STR$, TAB, VDU

Description

PRINT sends the calculated value of one or more BASIC expressions, in a formatted text form, to the OSWRCH output stream, which displays it on the screen and on any other enabled devices.

The PRINT statement is read from left to right. Elements are interpreted as follows:

Element Action
; Suppresses padding of <numeric> values until ,. As the last element, suppresses the final new line.
, Prints spaces to align the cursor with the start of a field, unless already aligned.
' Prints a new line.
~ Prints <numeric> values in hexadecimal until ; or ,.
SPC <numeric> Prints the given number of spaces.
TAB(<numeric>) If COUNT is less than the <numeric>, prints spaces until it is equal; if greater, prints a new line and the given number of spaces, making it equal.
TAB(<numeric>,<numeric>) Does a VDU 31,<numeric>,<numeric> to move the cursor to the given column and row. Does not alter COUNT.
<string> Prints the <string> without padding.
<numeric> Prints the <numeric> in decimal or hexadecimal form (see STR$), padded with spaces to the field width (see @%).

During printing, COUNT is zeroed by each carriage return, unchanged by two-argument TAB, and incremented by any other character. Where COUNT is an 8-bit quantity, a misalignment can occur when it overflows.

A new line is printed after the last element, unless it is ;.

Regregex 14:34, 13 November 2012 (UTC)