Beginner TI-83 BASIC
By: atom
This tutorial teaches the reader the basics of programming TI-83 BASIC

Lesson 1: How to start

Lesson 2: Your first program

Lesson 3: Variations on your first program

Lesson 4: Animation

Lesson 5: Working out bugs

Lesson 6: Programming on the graphscreen

Lesson 7: Where to go from here

Lesson 1: How to start

Let's just get started with how to write a BASIC program. To start a program, press PRGM, then left arrow, then enter. It will say Name= and type in the name of your program. For now, just type in "GUESS" because that will be your first program, then press enter. On the screen now at the top it will say the program's name and below it is a colon. This is where you begin writing you program. To write a program, you use cammands, such as IF, GOTO, and Output(. We will talk later about what each one does. You do not have to type the commands in by hand (in fact, you can't). Instead, there commands are located in various menu's. The menus will be different while you are in the program editor than when you are on the homescreen. For example, press PRGM. Instead of a list of programs, it has a list of commands. There may be more than one list of commands under each menu; use the left and right keys to move back and forth. To cancel, press CLEAR. Before you end this course, you will know what most of these commands do.

To quit the program Editor, press 2nd QUIT and you will return to the homescreen. To run the program, press PRGM and scroll down to the program you want to run and press enter. To delete a program, press 2nd Mem, then scroll to ALL and press enter. Then scroll down to the program you want to delete and press enter. If you want to copy all the commands from one program to another, open the program you want it copied to and press 2nd RCL. Then press PRGM and select the program you wish to copy. The program will start wherever the cursor is. This is also the way you rename programs (start new program with new name and RCL the old program name).

Lesson 2: Your first program

Go into your program GUESS (if you're not there press PRGM, then select GUESS and press enter). Type in the following command lines. Afterwards, we will see what they mean.

:randint(1,100)->A 	(randint is located in the math menu, number 5 under PRB)
:Lbl A 						(Lbl is located in PRGM, number 9 under CTL)
:Input "Guess=",B   		(Input is located in PRGM, number 1 under I/O)
:If B>A 					(If is located in PRGM, #1 under CTL, > is located in the TEST menu, number 3 under TEST)
:Disp "LOWER" 				(Disp is located in PRGM under I/O number 3)
:If A>B
:Disp "HIGHER"
:If A=B 					(= is located in the TEST menu, number 1 under TEST)
:Goto B 					(Goto is located in PRGM, number 0 under CTL)
:Goto A
:Lbl B
:Disp "You Win!"

Now, let's take a look to see what it all means. The first line ( :randint (1,100)->A ) is simply creating a random number. 1, 100 means that it is making a random number between 1 and 100. ->A means it is storing the random number in variable A, so we can use it later on. The second line ( :Lbl A ) is just creating a point in the program where we can go back to. To go back to this point, we would use Goto A, which we do later on in the code. In our case, it is to guess again if the number typed in does not equal the random number, you will try again. :If A>B means that if A (the random number) is greater than B (The number the user typed in), then follow out the next line, otherwise do not. So if A>B, Then excecute the next line ( :Disp "HIGHER" ). The next 2 lines reverse it, so that if B>A then it Displays "LOWER". After that, the lines :If A=B :Goto B means that if the number guessed is the same as The random number, then goto label B. Then it says Goto A, meaning to go back to Lbl A so that you can guess a new number. But if you guessewd the right number, then you will have already gone to Lbl B, therefore skipping that command. Then after Lbl B, it says :Disp "YOU WIN!". That means that the user knows he won because the Disp command means to output whatever is after that. In the next lesson you will learn a few ways to improve this program.

Lesson 3: Variations on the program

You can make the program you learned in the last lesson several different way. You may have noticed if you ran the program that data on the homescreen stayed in the program. To change thins, you just need one command. To insert something press [2nd][INS] and type what you want to insert. This should be the first line on of the program.

:ClrHome 				(ClrHome is located in PRGM, number 8 under I/O).

Now when you run the program it will get rid of the junk on the homescreen. The next thing you can do it let the user decide what numbers will be used to guess from. Put these commands directly after the first line:

:Input "NUMBERS=",G

Then change the next line to change :randint(1,100)->A to :randint(1,G)->A. This way it is making a random number from one to whatever was stored in G. What is stored in G is what was typed in.

The next thing you can do to make the program better is keep track of the number of trys. Insert a line somewhere before Lbl A which says :0->T This stares the number 0 in the variable T. Then, after Lbl A, insert a line that says, :1+T->T What this does is add 1 to the variable T every time you pass Lbl A, which is every time you make a guess. This won't do very much unless you tell the player how many guesses it took. For this you will learn a very important cammand, called Output(. It is in the PRGM munu, number 6 under I/O. What Output does is display something whereever you want on the screen, unlike with Disp, wish is put on the last unused line. Use Output(X,Y,"TEXT" where X is the row (1-8) and Y is column (1-16). For this example, erase the last line and type this in:

:ClrHome
:Output(2, 3, "YOU WIN!"
Output(4,1,"IT TOOK YOU"
:Output(4,13,T
Output(5,4,"TRYS"

What this does is (1)Clear the screen, (2)Output "You win!" (3)Output "It took you" (4)Outputs T, the number of trys it took (since it's not in quotes, it will use the number stored in T, not the letter T) and (5)Finish the sentence by adding "TRYS" to the next line.

Lesson 4: Animation

To make games, things will obviously need to move. Let's try making a new program whose only purpose is to make something move. Start a new program named anything you want. "TEST" is fine. Type in the following lines:

:ClrHome
:1->W
:Lbl A
:If W>1
:Output(1,W-1," " (notice there is a space in between the quotes)
:If W>1
:Output(8,W-1," "
:Output(1,W,"O"
:Output(8,W,"O"
:If W=16
:Goto B
:1+W->W
:Goto A
:Lbl B
:If W<16
:Output(1,W+1," "
:If W<16
:Output(8,W+1," "
:Output(1,W,"O"
:Output(8,W,"O"
:If W=1
:Goto A
:W-1->W
:Goto B

Now lets see what we've created. ClrHome, as you know, clears the screen. Lbl A creates an Label so that we can go to that point whenever we use the Goto command. If W>1 means that the next line will be carried out only if W (the number STORED in W) is greater than 1. Output(1,W-1," ") will put a space, which is a blank spot, where the moving object will be. Since W=1 the first time through, this command won't be done. Otherwise, it would try to put a space in column 0 which doesn't exist and give an error message. Not: the close paranthasis ) in output is optional. The next two lines do the same thing only in row 8, not row 1. These lines have erased the old object which was there and the next lines will create a new object that looks the same in a different column. This will make it look like it moved. Output(1,W,"O" will output "O" in the first row, in column W. To start, W=1, so it will go in the upper-left corner. Then we put the same thing in row 8. The next commands are: If W=16 :Goto B. This means that if the column W is 16 (the last column) then stop that and goto Lbl B. Then we add 1 to W ( 1+W->W ) so that the next time it goes to Lbl A the "O" will be in the next row. Then it says Goto A, so that it will repeat the whole process with the new number for the column W. At Lbl B it does the same thing only it brings the "O" back, the other way. Try runnung the program. Do you see Two Os going back and forth? You should turn upi the brightness of the screen because it goes so fast it's hard to see.

Lesson 5: Working out the bugs

No one who programs can get everything right the first time. There are going to be bugs, or problems, with the program. The TI-83 (an all TI-Calculators) will tell you what the problem is. When you run a program, it may stop the program and give you an error message. It will then give you the options of (1) Quitting and (2) Going to the problem and fixing it (you have to fix it yourself, though). If you select GOTO, it will take you exactly where the program is. Here are some of the most common errors and what they mean.

ERR:SYNTAX

This is probably the most common bug. It means you mistyped something or did something that doesn't make sence. For example, maybe you forgot to press enter between lines and typed: If A=BGoto C then it would give you a syntax error. Or maybe you typed something twice, like If A>>B. These are examples of Syntax errors.

ERR:DOMAIN

This error probably means you tryed to output something off the screen. The TI-83 has 8 rows and 16 columns, so if you typed: Output(9,20,"O" it would give you this message. However when using output, youy can type something longer than will fit and it will wrap to the next line. You just can't start something off the screen.

ERR:ARGUMENT

occurs when something is missing. If you just typed in "If", then it would expect something to follow it, and if there is nothing, it would give an ARGUMENT error. It would also occur if you didn't put the column in an OUTPUT command, like "Output(6,"O".

ERR:MEM

This is the Error no one wants. Your calculator is out of memory and couldn't finish the program. You'll have to erase some things.

ERR:OVERFLOW

You may have seen this one on the homescreen. It means that you tryed to create a number that is too big for the calculator.

Lesson 6: Programming on the graphscreen

Until now, you've only been programming on the homescreen. On the homescreen, you can't draw pictures; you can only use letters and variables. Also, you can only output the thing in 16 columns and 8 rows. If you use the graphscreen, you can do more. You can draw pictures and output thing in any pixel you want. In this lesson, you will learn how to program on the graphscreen. You must use different commands on the graphscreen.

A lot of these commands depend on the Window size. You can set the window size inside the program by pressing [VARS] [Window...], then whichever command you want. For example, you could type 1->Xmin to set the Xmin to 1. Note: if you get an error message "ERR:WINDOW RANGE" it means that your Xmin is bigger than you Xmax, or the Ymin is greater than the Ymax, which can't happen.

Note: Most of these commands appear in the Draw Menu, [2nd][PRGM]. If you use these commands, the calculator will auto matically take you to the graphscreen.

ClrDraw-this is the same thing as ClrHome but for the Graphscreen.

Line( An important one. As you may have guessed, it draws a line. You put in four variables: X1, Y1, X2, Y2 in that order. So if you wanted a line going from 3,4 to 8,7 (X and Y coordinates), you would use Line(3,4,8,7). Put a zero (0) after those four to erase the line. For examle. If you wanted to erase that line (3,4,8,7) then you would type Line(3,4,8,7,0).

Horizontal Makes a horizontal line at the place on the Y axis which you specify. For example, if you want a horizontal line on through 0,0, you would put "Horizontal 0".

Vertical Same as Horizontal only it creates a vertical line.

Circle( Draws a circle. It uses 3 variables. The first 2 are x and y coordinates of the center; the last is the radius. So if you wanted a circle centered at 0,0 and a radius of 5, you would write Circle(0,0,5)

Text( This command is like Output but on the graphscreen. The only difference is that you use pixels instead of rows and columns. The pixels are NOT affected in any way by the Window range. So if I wanted to write "HELLO" 5 pixels to the left right of the left side of the screen and 34 pixels down, I would write Text(5,34,"Hello".

Pt-On(, Pt-Off( and Pt-Change( draws a point at the x- and y-coordinates specified. If you wanted a point at 4,6 then write Pt-On(4,6). You can also make different shaped points by adding 2 or 3 to the end of it (i.e. Pt-On(4,6,2). Pt-Off does the same trhing only it turns the point off. Pt-Change( changes the status of that point. So if it was on it would change it to off and vice-versa. Note: These commands are listed under POINTS on the [Draw] menu. These can help draw pictures.

Pxl-On(, Pxl-Off(, Pxl-Change(, and Pxl-Test(. These are almost the same as the above ones. They turn on and off pixels. The major difference is that the spacing is like Text(, where it uses pixels from the side of the screen, and is not affected by Window Range. Another difference is that you cannot use different shapes; it must be a pixel. The pxl-Test tests to see if the pixel is on or off. It returns 0 if it is off and 1 if it is on.

Most of the commeands, such as If, Goto, etc. are the same on the graph screen. Two that do NOT work are "Output(" and "Disp". These will bring you back to the homescreen.

Lesson 7: Where to go from here

Congratulations! If you have read and tried this course then you are well on your way to being an expert programmer. What should you do now? Well now that you know the basics, you can do anything you want. I learned BASIC almost entirely by trial and error. Try making games and programs harder and harder.... A good game to help you learn is Black Jack because you can make an easy one and keep adding to it. Soon there will be an Advanced BASIC for the TI-83. But before you take that, I strongly recommend that you experiment with Basic. That's the best way to learn. It may be frustrating, but trying to figure it out will teach you. If you ever need any help finding out how to do something or you think you'll explode if you don't get something to work, feel free to E-mail me. I'd be glad to help you, even if it is a "stupid" question. Now you are on your own!