Micropower |
Volume 1 · Number 3 · November 1981 |
Page 4 of 33 |
---|
In setting out text on the screen or for printing there are a number of other useful functions in BASIC which you can use with the PRINT statement, viz.
SCREEN X,Y . . . places the cursor on the Xth position across and Yth line down.
PRINT TAB(I) . . . moves the cursor to the Ith horizontal tab position.
PRINT SPC(X) . . . moves the cursor X spaces along from the current position.
POS(I) . . . returns the current position of the cursor. This is useful where the cursor might finish up in one of a number of different tab postions after following alternative routes to reach the current program line. In order to obtain a satisfactory print layout you could insert a line as follows:–
20 R=POS(I):IF R>25 THEN PRINT
Note (I) is only a dummy argument in this instruction, that is, because POS is a function, not a command, it has the format of a function, but what you put within the brackets is immaterial.
Since extra memory chips are so cheap these days saving space by shortening Basic lines has few advantages. However, it is quite often annoying to find that you are one or two characters in excess of 48 and therefore must have yet another line. You will no doubt have discovered by now that in many situations it is not necessary to use the second quotation mark when printing or defining strings. (e.g. [X$=”FRED] is acceptable as a statement on its own or at the end of a multiple-statement line.)
Now consider the following lines:
20 V=99:X$="15th":Y$="JAN":Z$="1981" 30 PRINT "Amount";V;TAB(25);"Period ";X$;" ";Y$;" ";Z$
T12‘15th’ and ‘JAN’ require closing quotes but ‘1981 ’ does not. Line 30 will not fit onto one screen line, and could only be entered by using direct entry of the single-byte reserved words from the keyboard, using the ‘Graphics’ key. But several characters can in fact be left out since the second quotation marks can double for the statement separators. i.e.
30 PRINT "Amount"V;TAB(25)"Period "X$" "Y$" "Z$
Like PEEK & POKE , DEEK & DOKE allow you direct access to the data held in
Page 4 of 33 |
---|