Beginner TI-80 BASIC
By atom
An introduction to programming BASIC on a TI-80 calculator.

How to Start
Your first program
More useful commands
Conclusion


Lesson 1: How to start

Let's jump right into your first program. This first lesson will tell you how to set up a program and how to work with it. After this lesson, you will begin to learn the actual code.

To start a program, press [PRGM] then [Left arrow] then [ENTER]. It will ask you for a program name. For now, type in "GUESS" because that will be your first program (lesson 2).

You do not type in the letters when you are in the program editor, for then it won't work. You go into different menu's where different commands are located. The menus are different from when you were on the home screen. For example, press [PRGM]. It doesn't have programs; it has commands. You will use these commands later to edit your program. To get back to the home screen, you press [2nd] [QUIT]. It automatically saves as you go along. To edit a program, press [2nd] then the right arrow key.

To delete a program, press [2nd] [MEM] [2:DELETE] and select the program you want to delete. Then press enter. Now let's start programming!


Lesson 2: Your first program

Go into the program GUESS. If it hasn't been created yet, create it. Then type the following commands (do NOT type what's in parenthesis; that's for your reference)

:CLRHOME (located in the I/O menu under [PRGM], number 4)
:RANDINT(1,100)->A (RANDINT( is located in the [MATH] menu, number 5 under PRB, -> is the STO> key) 
:LBL A (LBL is located in the [PRGM] munu; number 7 under CTL)
:INPUT "GUESS=",B (Input is located in the [PRGM] menu, number 1 under I/O) 
:IF B=A
:GOTO B (GOTO is located in the [PRGM] menu, #8 under CTL)
:IF B< is in the [Test] menu, number 5)
:DISP "HIGHER" (DISP is located in the [PRGM] menu, number2 under I/O)
:IF A
:DISP "LOWER"
:GOTO A
:DISP "YOU WIN!" (! is in the [MATH] menu, number 4 under PRB)
:DISP "1=YES, 2=NO"
:DISP "PLAY AGAIN?",E
:IF E=1
:GOTO E

Now, let's see what it all means. The program is a guessing game where you guess the random number drawn. Try running the program. Now let's go through it line by line so you understand what you did and you can do it with different programs on your own. The first line, :INPUT "NUMBERS 1 TO",C is asking the user of the program what possible random numbers to be drawn are. ,C stores the number that the user types in in the variable C which can be used later (it could be any letter A-Z). The next line, :LBL E creates a label to which we can go back to at any time. We would use the command :GOTO E and the program would go right back here, to LBL E. LBL's with the TI-80 can be A-Z and 1-10. Later on in the program, we do go back to LBL E. The next command, :CLRHOME, simply clears the homescreen. RANDINT(1,C)->A is creating a random number anywhere from 1 to the variable stored in C. Remember a few lines back when we said :INPUT "NUMBERS 1 TO ",C ? What ever the user typed in then was stored in C and is now used to decide what random numbers to be used. We could have said RANDINT(1,100)->A, which would have created a random number from 1 to 100, ignoring what the user typed in. Let's move on. YOu should know what :LBL A does. It is the same thing as :LBL E but to go back to this we would use :GOTO A.

This is where the guessing starts. The next line asks for a guess at the number :GUESS=",B. The ,B part stores what the user typed in in the variable B. :IF B=A says that if B, which is the number that the user guessed, is equal to A, which is the random number, then carry out the next line. In other words, if you guess right then do what's next otherwise do not. Then the next line says :GOTO B. So if B=A then the program will skip the following steps and go straight to LBL B. Next comes :IF B

Next comes :LBL B. The user is at LBL B because A=B (remember back several lines, at GOTO B?). So you win. :DISP "YOU WIN!" is just displaying those words. The next line displays "1=YES, 2=NO", and after that it asks the user to type 1 or 2 to play again. :IF E=1 as you know makes it so that if E (the number just typed in) equals 1 then do the next line.The next line says GOTO E, so it plays again. If E=2 then nothing will happen so the program automaically ends. What do you think would happen if the user types in 3?


Lesson 3: More useful commands

Let's talk about some of the other commands you will need to make your own programs.

THEN: THEN is used with if. You would usually se them if you wanted more than one thing to happen. For example

:IF A=1
:THEN
:3->A
:DISP "1"
:DISP "YOU WIN!"
:END

END is important because it marks the end of what happens with the IF THEN statements. If you left out the END, then the whole rest of the program would only work if A=1!

ELSE: ELSE is used with IF and THEN. It makes it so the next line occurs only if the statement ISN'T true. If you said it in a sentence, it would be like "otherwise". For example, "If it is 12:00 then eat lunch, other wise walk the dog", where "otherwise" is else. On your calculator, this is how you would type it in:

:IF A=1
:THEN
:DISP "A=1"
:DISP "YOU WIN!"
:ELSE
:DISP "2"
:DISP "YOU LOSE."
:END

PAUSE Pause simply pauses the program. It makes it so you have to press enter to continue.

CLRHOME Clears the home screen so that it is blank.

RAND comes up with a random decimal between 0 and 1. For example RAND->A would store a decimal between 0 and 1 in the variable A.


Lesson 4: Conclusion

Since there is not very much you can do with a TI-80, this is all there is to teach you. The way I learned was just by trial and error (mostly error). This course has given you a basic overview so that you won't have to start from scratch. What to do now? Well, try looking at the source code of some programs. If you want to see some programs, go to the program section of our site. Read through each one carefully to see if you understand them. Try programming your own. Blackjack is a very good game to try, because it is rather easy and you can expand on it once it's done.

I hope you learned a lot from this lesson. I programmed my TI-80 so much that I later bought the TI-83, TI-92 and TI-86. But you can do so much with just the TI-80.