SECTION G - PRIMER FILE PRIMER.G CONTROL CODES ************* In this section we introduce some code combinations which affect the screen display and the output to the printer. The American Standard Code for Information Interchange (ASCII) is the recognised standard for exchanging information between computers and allied equipment. The standard ASCII table consists of the numbers 0 to 127 (Hexadecimal #00 to #3F), each number representing a symbol, among which are the letters of the alphabet, both in upper and lower case,numbers 0 to 9, punctuation marks, the space and many others. Your PCW has added to this with extra symbols up to 255 (Hex.No #FF). Symbols with numbers in the range 0 to 31 are also interpreted as CONTROL CODES, that is they can, when used correctly, affect the output to screen or printer. A full table as applied to your PCW can be seen in the CP/M manual supplied with the machine in appendix I.4, page 113, and control codes are discussed in appendix III, page 139. ============================================= = In PRIMER we shall begin to see how these = = codes and Command codes are used in BASIC.= ============================================= Many of the symbols on the ASCII table can be typed to screen or printer direct from the keyboard. These include, of course, letters, spaces, numbers etc., but some cannot be typed directly. For these the function CHR$ is used. For example, the command line PRINT CHR$(35) would print # on the screen since 35 is the ASCII code for # in decimal. Conversely the command line PRINT ASC(#) would print the number 35 The programs following this text demonstrate this. ESCAPE SEQUENCES ================= The number 27 in the ASCII table has a particular significance for us as it represents ESCAPE. In CP/M it can be accessed simply by pressing the EXIT key, but in BASIC we must use the CHR$(27) form. This used in conjunction with other symbols can produce many interesting effects. In PRIMER, as an introduction we shall see how to use it to clear the screen.This is done by typing the line PRINT CHR$(27)+"E" and then pressing [RETURN].Similarly, to 'HOME' the cursor i.e. to place it in the top left-hand corner type PRINT CHR$(27)+"H" and press [RETURN]. These two commands can be, and usually are, combined to produce a blank screen with the cursor homed. The command line is:- PRINT CHR$(27)+"E"+CHR$(27)+"H" or you may also see it written PRINT CHR$(27);"E";CHR$(27);"H" : Either way it is a pain in the **** to keep typing this line. Luckily, it can be typed once in a program and represented by a variable. This can be seen in line 10 of TUTOR where it is made equal to cls$, so to clear the screen you type 'PRINT cls$ 'only. Other 'Escape sequences' can be treated similarly. Following the CHR$ and ASC programmes you will see lines 10 to 90 listed which show the screen clearing codes plus some others used in TUTOR. Although this section may seem complicated, in a short time you will think it child's play. For the moment it is sufficient to be aware of the existence of these codes and to recognise the CHR$(27) as the ESCAPE code. We shall return to them in greater detail in the next part,INTER End of file PRIMER.G CAPE code. We shall return to them in greater detail in the n