Chapter 2

We send the special code CHR$ (27), which means “<Escape>,” down the line immediately preceding a control code that needs that <Escape>. These special “code pairs” are logically called “Escape codes.” We can either build them into a BASIC program or send them from the command level, as we did earlier with the simple stand-alone control codes. We will learn to use each “Escape code” as it is needed.

Our First Escape Code

<Escape> “K” stands for KICK it into the GRAPHICS MODE. As part of the graphics mode series of commands we must tell the printer how many columns of graphics we intend to print. The next two codes, CHR$ (60) and CHR$ (0) tell that tale:

CHR$ (60) means “expect 60 characters.” Any additional ones will be printed as text. If less than 60 are sent, the printer will just sit and wait until that quota is satisfied.

CHR$ (0) tells the printer that we decline to send another 256 charac- ters. If that latter point seems a bit obscure, don’t worry. We’ll get a more detailed explanation of what that means and plenty of practice in the graphics chapter. Just follow along with the act, for now.

Model I TRS-80 users note: the Model I cannot send a CHR$ (0) reliably to the printer. Try CHR$ (2) instead or see Appendix D for special instructions to deal with this problem.

Return

RETURNing from our GOSUB, type in line 30, but don’t RUN it, yet. We have to create some graphics to send at the same time.

30 PRINTTAB (22) CHR$ (27) "K" CHR$ (60) CHR$ (0);

Lines 40 and 60 are the loop that sends the 60 characters from line 50 to the printer. Actually, the loop sends a few more than 60, (2510.4 = 62.5), but we told the printer to only accept 60, so it ignored the “overage.”

Add these lines in preparation for the big one.

40 FOR I=1 TO 25 STEP .4

60 NEXT I : PRINT

20