PROGRAMMING THE TI
If you use these editing keys and built-in programmers' commands, you'll soon discover how fun and easy-to-use the TI-99/4A can be.
You are typing along writing a program or "keying-in" one from COMPUTE! Magazine when — oops! — you make an error. Hold it! Don't type the whole line over! Take advantage of the easy-to-use editing capabilities built in to the TI-99/4A.
Take a look first at the arrow keys (found on letters E, S, D, X). You thought they were just for games? They will probably be the most used editing keys once you get used to them. Suppose you have typed lines 100-150 and look up at the screen and notice you want to change the number in line 130:
130 CALL SCREEN(14)
Type in 130 then hold the function key (FCTN) down while you press the down arrow ↓. (It might be best to follow through this article as you sit at your TI-99/4A.) You'll notice line 130 comes up at the bottom of the screen with the cursor at the first position. Now press FCTN and the right arrow. The cursor will go toward the right. You may go one space at a time, or hold the key and it will repeat. Go over to the 4 in 14. Stop right over the 4 and type 6. Press ENTER, and the line will now be
130 CALL SCREEN (16)
Any characters you don't want to change you can just pass over with the arrow key. Change the character you want, then press ENTER — you don't need to go to the end of the line either.
Now suppose you don't like color 16 (white) and decide you want color 6. Type 130 then FCTN ↓ Use FCTN → to get over to the 1 in 16. Stop right on top of the 1. Now press FCTN and 1, which is DEL, for DELete. Now press ENTER and you should have
130 CALL SCREEN(6)
Try another function key. Type 130 then FCTN ↓. Use FCTN→to go on top of the 6 and type 2. Just a second, though. You don't want screen 2; you want 12. Use FCTN ← to back up one spot (cursor on 2). Press FCTN 2 for INSert. You won't notice anything right away, but now type 1 — you have color 12. Press ENTER and your line has been changed.
The left arrow, right arrow, and DELete keys have the automatic repeat feature by just holding the key down. The INSert key needs to be pressed just once and characters will keep being inserted as you type until you press ENTER, DELete, or one of the arrow keys. To delete or get rid of a whole line, type the line number and then press ENTER.
Two more handy editing keys are the up arrow and down arrow. Let's assume you have the following lines:
200 CALL HCHAR(3, 5, 42) 210 CALL HCHAR(3, 8, 42) 220 CALL HCHAR(3, 20, 33)
You RUN your program and discover the graphics needs to be a line lower — the row value needs to be changed from 3 to 4.
Type 200, press FCTN ↓, and use the right arrow to change the 3. Instead of pressing the ENTER key, press FCTN ↓. After line 200 has been edited, the very next line, line 210 in this case, will appear for editing. Likewise, the up arrow will give you the line just before the one on which you were working.
Two other editing keys you should be aware of are ERASE (FCTN 3) and CLEAR (FCTN 4). You may already be familiar with CLEAR. If you are running a program and want to stop, FCTN 4 will interrupt the program. (QUIT, FCTN =, will stop the program, erase it from memory, and return to the TI title screen; CLEAR stops the program but it is still in the computer and you may either CONtinue or RUN.)
CLEAR has another function while you are programming. If you start typing a line and decide you don't want that line after all, press CLEAR. The cursor will go to the next line and the line you were working on is ignored. ERASE will erase the line that you are working on.
The other function keys you see along the top row of your keyboard are used in some of the command modules and are described in the manuals accompanying the modules.
Some helpful commands for programmers are LIST, NUM, and RES. As you are writing a program, each command needs a line number. When the program is RUN, the computer executes each line in numerical order. The command LIST will list your complete program in order. As your program lists, if it is too long for one screen, the lines scroll off the top. If you want to stop the listing, press CLEAR. If you want to list only part of your program, just list the lines you wish:
|LIST-200||All lines up to and including line 200|
|LIST 200-300||Lines 200 to 300 inclusive|
|LIST 300-||Lines 300 to the end|
When you're typing in a program, it will save time and reduce the chance for error if you let the computer type the line numbers. Type in the command NUM (for NUMBER). The computer will automatically start with line 100. Now type in CALL CLEAR and press ENTER. The computer enters line 100 and starts you on line 110. The NUM command automatically increments the line numbers by 10.
You may start anywhere — for example, type NUM 3220 and press ENTER. Your program starts with line 3220 and increments by 10.
Yes, you can change the increments also. Type NUM 200,5 and you'll start with line 200 and increment by 5 (line 200, 205, 210, etc.). The general form is: NUM initial line, increment.
If you want the program to start with line 100 but the increments to be 7 instead of 10, you may use NUM ,7.
To get out of the automatic numbering, just press ENTER after the line number or CLEAR. You'll also notice that if you have a program in the computer and type NUM the computer will show you what is on that line. If you want to keep the line as is, just press ENTER.
RES is a command that stands for RESEQUENCE. You've been programming and adding lines here and there and want it to look nice again, all numbered by tens. Type RES and press ENTER. As soon as the cursor reappears, your program is resequenced or renumbered, including all line numbers referenced in other lines. Try this sample:
10 CALL CLEAR 12 CALL SCREEN(14) 20 FOR I = 1 TO 8 30 CALL SOUND(500,-I,2) 35 GOTO 20
Now type RES and press ENTER, then LIST. The lines are resequenced, starting with 100 and incrementing by 10. Like the NUM command, you may specify the starting line number and the increment: RES initial line, increment.
Try RES 10 then LIST.
Try RES 1,1 or RES ,5 and experiment with your own numbers.
Quite often I like to start writing programs with line numbers incrementing by 10. Type in NUM and start programming. If the program has several branches, I may start one branch at 1000 (NUM 1000), another at 2000, etc. Leaving gaps in the line numbers makes it easier to add lines later.
For example, if I have a line 200 and the next line is line 210, I may easily add lines in between by numbering them 202, 204, etc. But what if I have to add 15 lines between lines that are only ten apart? RES ,50 will spread the lines apart and allow more numbers in between. Of course, when I'm through with the program, I RES so the program starts at 100 and increments by 10, and you can't tell where I have planned poorly and had to add lines.