PRINT

BASin

PRINT

Statement/Command

PRINT displays data on the screen. The data may be any single character or a sequence of characters. A PRINT statement may incorporate other keywords to define the position and colour of the data.

How to use PRINT

PRINT may be used alone or it may be followed by data. This data may be in the form of any numeric or string expressions, or a mixture of these.

When using PRINT with data, two or more separate items must each be separated by a semicolon, comma or apostrophe.

Certain other keywords may be inserted in any order between PRINT and the data, provided each statement formed by the keyword ends in a semicolon. These keywords are CHR$, TAB, AT, INK, PAPER, FLASH, BRIGHT, INVERSE or OVER.

PRINT with strings

PRINT alone or followed by a null string ("") displays a blank line and moves the print-position to the beginning of the next line.

PRINT followed by a string constant (any characters within double quote marks) displays the characters as they appear between the quote marks. The command

PRINT "3/542/76/32"

displays

3/542/76/32

PRINT followed by a string variable or expression displays the string or strings they represent.

PRINT with numbers

PRINT followed by any numeric expression displays the expression's value. Numbers are displayed in decimal notation with up to eight significant digits and no trailing zeros after the decimal point.

Very large numbers and very small numbers are displayed in a shorter scientific notation, as two figures separated by the letter E. This indicates a number in which the first part (the mantissa) is multiplied by 10 to the power of the second part (the exponent). The command

PRINT 3/542/76/21

for example displays

3.4680798E-6

PRINT formatting with punctuation signs

PRINT followed by items of data separated by a semicolon displays the items placed next to each other without a space. The command

PRINT 1;2;3

displays

123

PRINT followed by items of data separated by a comma displays each item at the beginning or in the middle of the a line depending on the position of the first item. The command

PRINT 1,2,3

displays

1               2
3

PRINT followed by items of data separated by an apostrophe displays the item after the apostrophe at the beginning of the next line. The command

PRINT 1'2'3

displays

1
2
3

If a PRINT statement or command ends with a semicolon, comma or apostrophe, then the item displayed by the next PRINT statement is affected in the same way.

PRINT and other keywords

PRINT may be followed by TAB, a numeric value, a semicolon and then an item of data, for example

60 PRINT TAB x;a$

The value following TAB (x above) is rounded to the nearest integer if necessary and is then divided by 32 and the remainder returned to give a value of between 0 and 31. The item of data is then displayed at this column position in the same or the next line.

PRINT may be followed by AT and then two numeric values separated by a comma, a semicolon and an item of data. For example,

50 PRINT AT l,c;"Data"

The first value (l above) may range from 0 to 21 and defines the number of the line or row in which the data will be displayed. The second value (c above) may range from 0 to 31 and defines the number of the column in which the first character or digit of the data will be displayed. Non-integer values are accepted and rounded to the nearest integer. The command

PRINT AT 11,16;"*"

displays a star in the centre of the screen.

PRINT may also be followed by one or more CHR$ functions. See CHR$ for more details.

PRINT and colour keywords

The display produced by PRINT is affected by colour statements or commands given by INK, PAPER, FLASH, BRIGHT, INVERSE and OVER that are currently in operation. PRINT may also be followed by one or more of these six statements each followed by a semicolon before the item of data, for example

50 PRINT AT 11,16;INK 2;FLASH 1;"*"

The item of data is then displayed with the attributes specified by the colour keyword(s). These attributes are local and only apply to the item displayed. Following execution of the PRINT statement, they revert to their default or previously declared global values.

Format

  • PRINT [TAB int-num-expr;] [AT int-num-expr,int-num-expr;] [CHR$ (int-num-expr);] [num-expr] [string-expr] [;] [,] [']

See also

Chapter 2, Chapter 15.