Volume 1, Number 3 – November 1981

Page 3 of 33


by Viktor . . . . . Part, the third


Since most of us cut our programming teeth on the PRINT statement, there is not much point in covering acres of paper in explanations and illustrations – however for the benefit of those just beginning I will summarise the ground rules. [INPUT “Enter SKILL LEVEL”; X$:IF X$= “ADVANCED” THEN GOTO(next section)]

The PRINT statement outputs to a terminal, usually the screen or a printer(or both). It operates from the current position of the cursor. If used on its own, a carriage return/​line feed(CR/LF) is output, thus placing the cursor at the start of the next line.

You can also print numbers [PRINT 5] , the answers to calculations [PRINT 5*6 (=30)], the value of variables [PRINT A (=10 where A=10)], string literals [PRINT “Fred”], strings [PRINT X$ (Nascom-where X$ has been defined as “Nascom”), plus a whole series of intrinsic functions which are listed in the manual. Useful examples are:–

PRINT CHR$(X) – where X has any ASCII value from 0 to 255. For example, CHR$(65) prints the letter A, CHR$(181) prints a small human figure, if your system is equipped with the Nascom 2 graphics ROM.

PRINT FRE(0) – gives you the remaining memory space available for your BASIC program.

PRINT SQR(X) – outputs the square-root of X.

In formatting text it is obviously important to know where the cursor will be positioned after the computer has carried out a PRINT instruction. If a PRINT statement is terminated with a colon, or if the line ends without a special terminator, the next PRINT statement will begin at the start of the next line, the Nascom having output a CR/LF. However, if you end the statement with a semi-colon, the next PRINT statement will start at the next available space; e.g.

10 FOR A=1 to 5:PRINT A;:NEXT will give you:–

1 2 3 4 5

Note that a space is output in front of each number – if you PRINT a negative number this space will be occupied by a minus sign.

A further modification, available within the PRINT statement itself, is the use of commas to divide the output into zones. PRINT 1,2,3 puts 1 in position 0,2 in position 14 and 3 in position 28. If you not redefined WIDTH then the third zone is 20 characters wide. If a zone is completely filled or exceeded the instruction will still be carried out but the cursor will then be moved to the start of the next free zone.

Page 3 of 33