Volume 1 · Number 2 · September 1981

Page 23 of 33

return to Basic with Z. Notice that the rate at which characters are output, for example when you LIST a program, is now dependent on the baud rate set for the cassette interface, because data is sent to the serial port as well as the screen. You will find that you can now enter up to 72 characters in each Basic line. However, editing facilities are severely restricted, and I would personally recommend that you stick to a maximum of 48 characters per line, because the slight increase in memory used is more than compensated for the ease of editing produced.

And Now For The Fun!!

20 POKE 3017 + I +((48 - LEN(Z$))/2),ASC(MID$(Z$,I,1))

The above bit of code, or something similar, is often found at the beginning of Basic programs. It writes the program title in the centre of the top line of the screen; this roundabout method has to be used because Basic PRINT command will not write to the top line if the system monitor is Nas-Sys 1. So what is happening? It is best to break the program down into its individual commands and functions, and study each in more detail. Apart from the CLS command, which merely uses a monitor to clear the screen, these are, in order in which I shall look at them:

FOR . . TO . . STEP . . NEXT


This command directly modifies memory location X, changing its contents to Y. In the previous article we changed screen locations £09E3 from a space (£20) to a ‘bell’ (£07) using the monitor. The same result in Basic is produced by entering POKE 2531,7. Here basic, as always, uses the decimal value for the memory location and the number being inserted (9x256 + 14x16+3=2531). Thus to insert the letter A in this position you would enter POKE 2531,65 (A is represented by the hexadecimal code £41, and 4x16 + 1 = 65). Of course, you can use POKE to modify any memory location, not just the screen RAM. For example, many Basic programs use sections of machine code either for increased speed of operation , or to do something which cannot be done by Basic. The code is often stored in the Basic program as a list of decimal numbers which are then POKEd into a suitable space. The two-byte start address of this machine code is then stored in locations 4100 and 4101, so that the Basic interpreter knows where to find it when needed. This can then be done by two POKE instructions, but it is more usual to use the DOKE instruction, which I shall seal with in the next article. However, you must be very careful when

Page 23 of 33