You will recall that a PRINT statement has a list of items, each one an expression (or possibly nothing at all), & that they are separated by commas or semicolons. There are two more kinds of PRINT item which are used to tell the computer not what, but where to print. For example, PRINT AT 11,16; "*" prints a star in the middle of the screen.
AT line, column
moves the PRINT position (the place where the next item is to be printed) to the line & column specified. Lines are numbered from 0 (at the top) to 21, & columns from 0 (on the left) to 31.
moves the PRINT position to the column specified. It stays on the same line, or, if this would invoke back-spacing, moves on to the next one. Note that the computer reduces the column number modulo 32 (it divides by 32 & takes the remainder); so TAB 33 means the same as TAB 1.
PRINT TAB 30,1;TAB 12;"CONTENTS";AT 3,1;"CHAPTER";TAB 24;"PAGE"
(This is how you might print out the heading of a Contents page, with 1 as the page numbers.)
Some small points:
(i) These new items are best terminated with semicolons, as we have done above. You can use commas (or nothing, at the end of the statement), but this means that after having carefully set up the PRINT position you immediately move it on again - not usually terribly useful.
(ii) Although AT & TAB are not functions, you have to type the function key (shifted NEWLINE) to get them.
(iii) You cannot print on the bottom two lines (22 & 23) of the screen because they are reserved for commands, INPUT data, reports and so on. References to the 'bottom line' usually mean line 21.
(iv) You can use AT to put the PRINT position even where there is already something printed; the old stuff will be overwritten.
There are two more statements connected with PRINT, namely CLS & SCROLL.
CLS Clears the Screen (but nothing else).
SCROLL moves the whole display up one line (losing the top line) & moves the PRINT position to the beginning of the bottom line.
To see how this works, run this program:
20 INPUT A$
30 PRINT A$
40 GOTO 10
PRINT items: AT, TAB
1. Try running this:
10 FOR I=0 TO 20
20 PRINT TAB 8*I;I;
30 NEXT I
This shows what is meant by the TAB number's being reduced modulo 32. For a more elegant example, change the 8 in line 20 to a 6.
Previous: Chapter 16 Next: Chapter 18