Begining TI-89 BASIC Programming
By Anonymous
An introduction to programming TI-89 BASIC

Lesson #1

An introduction

Why should you use BASIC? On the new 89 it is an incredibly powerful language. It has support for user defined functions, local variables and much else. It is easier to learn and program then assembly, just slower to run.

Hello World

Time to make your first program! In the APPS menu select #7, Program Editor, and then New. Enter a name for your program in the Variable field, call it "hello". Press enter.

Now you're in the program editor. Before you type anything your screen should look like this:

On the blank line type in Disp "Hello". Your program should now look like this:

:hello()
:Prgm
:Disp "Hello"
:EndPrgm

Quit the program editor and return to the home screen. On the command line enter hello() and press enter. You should be transported to the PrgmIO screen and if everything worked hello will be written to the screen. Press F5 to return to the home screen. If you should want to delete your program, go to the VAR-LINK menu, highlight it and press <--.

I/O Stuff

Now that you know the basics of creating and running a program we can get to work. In this next program you will create a dialog box that asks the user for input, process that input, then report back to the user.

Create a new program called mydialog. Mouse down to the empty line in the initial program. We're going to create a dialog box that asks the user for two numbers to add. All the commands can be found in the F3 menu or typed in off the keyboard.

:mydialog()
:Prgm
:Dialog
:Title "My Dialog Box"
:Text "My Dialog Box Adder"
:Request "Add",a
:Request "And",b
:EndDlog
:a+b->c
:Disp c
:EndPrgm

Now run the program. Does the output surprise you? The input from the Request command is a string, not a number. We work around this with the expr( command.

:mydialog()
:Prgm
:Dialog
:Title "My Dialog Box"
:Text "My Dialog Box Adder"
:Request "Add",a
:Request "And",b
:EndDlog
:expr(a)→a
:expr(b)→b
:Disp c
:EndPrgm

Now when the program runs the sum of the two numbers will be returned. Now as amazing as this program is, its not too powerful. What if you wanted to subtract? Multiply? Divide? We can add a drop down menu that lets the user choose the operation to be performed on the two numbers.

:mydialog()
:Prgm
:Dialog
:Title "My Dialog Box"
:Text "My Dialog Box Adder"
:Request "Add",a
:Request "And",b
:DropDown "Operation",{"+","-","*","/"},d
:EndDlog
:If d=1
"+"→d
:If d=2
:"-"→d
:If d=3
:"*"→d
:If d=4
:"/"→d
:expr(a&d&b&"→c")
:Disp c
:EndPrgm

When you run this new program you should be able to specify the operation and the operands and get the right answer. Congratulations! You have completed lesson 1.

Learn More

This lesson hasn't covered everything about I/O. In fact no lesson will completely cover the material. They will however give you a decent background in the topic. If you want to master programing you need to program, a lot. Look at someone else's code, join a mailing list, and ask questions. There are all sorts of built in functions and stuff on the 89, they are all documented in the guidebook that came with your calculator. Look up what you want in the index, it's probably there.