Getting Started with TI-Basic

TI-Basic is the built-in programming language of the TI calculators. You can create TI-Basic programs on the computer (using the Graph Link or TI Connect software) or on the calculator itself (through the Program editor). Knowing TI-Basic is important because it is one of the main ways that people use their calculators. If you are unable to program in TI-Basic, you will not be able to effectively communicate with others concerning your calculator.

Advantages of TI-Basic

There are several advantages of programming your calculator in TI-Basic. First, and foremost, it is the most well known programming language. With most high schools requiring TI graphing calculators for math and science classes, TI-Basic is often used by students to make small math or science programs. For many of these students, TI-Basic is the first programming language they have ever used.

Second, you don't need a computer to write TI-Basic programs. This is why people are able to quickly write programs in school. Assembly programs need to be written on a computer, however. This is because Assembly programs are converted into machine code with an assembler and several other programs. These programs are currently only available on computers.

Third, TI-Basic is the simplest calculator programming language to learn. In TI-Basic, most of the commands are easily understood. The commands are written in plain English or easily comprehended abbreviations: Disp,Dec, etc. In addition, the commands are generally self-explanatory. For example, it is not very hard to recognize that the Menu command causes a menu to be printed on the screen.

Lastly, if you mess up in TI-Basic (your program has an error), it just gives you an error message. If an Assembly program has an error, however, the results wouldn't be as good. Depending on the severity of the error, you can cause your calculator's RAM to be cleared, or even leave your calculator in an endless loop, making it completely useless. TI-Basic does not have that problem, because no matter where you are in a TI-Basic program, you just have to press the ON key to stop execution.

Disadvantages of TI-Basic

TI-Basic does have some disadvantages. Its main disadvantage is its speed. Because TI-Basic is converted by the calculator into machine code before it is executed, it loses much of its speed. Doing anything involving calculations, getting user input or drawing graphics is quite slow in TI-Basic. Really, the speed of TI-Basic comes nowhere close to the speed of Assembly. You just need to play an Assembly game (such as Super Mario) to see the great difference in speed.

The other disadvantage of TI-Basic is that it is does not have access to many of the calculator's built-in features and functions (which Assembly does). This is purposely done by to prevent potential misuse. Besides lacking full access to the hardware, the drawing functions in TI-Basic are just points, pixels, lines, and circles (nothing too fancy).

Setting Up the Computer Environment

Before you can start programming, you need to set up the computer environment. Because the calculator's screen is relatively small and using its keys to type is rather cumbersome for writing larger programs, programming on the computer is often used as an alternative. There are several different tools available for you to use:

Making Programs

A program is an organized, step-by-step set of instructions. When executing a program, the calculator behaves in a predetermined manner, performing the instructions in a sequential order. The amount of free RAM is the only limit on the number and size of programs.

When making programs, there is a general order that you follow. You first need to create the program, then you edit the program, and finally you execute the program. Every program will go through this process, with the editting and executing being done numerous times to make changes or fix errors.

Create a Program

To create a program, you have to first go into the Program menu. This can be found by pressing the PRGM key. Then, press the right arrow twice > > to go to the NEW menu. Select 1:Create New and press ENTER. The Name= prompt is displayed, and alpha-lock is on. You now have to enter a name.

Here are some things to remember about naming programs:

  1. Each program must have its own unique name.
  2. Program names can only be eight characters or less.
  3. The characters must be A-Z, 0-9, or θ.
  4. The first character must be A-Z or θ.

Also important, you should choose a program name that actually relates to your program (such as its title). And, if your program is insignificant (such as a subprogram for a larger program), start it with θ or Z so that it appears at the bottom of the program list.

After you have typed in a name that you are satisfied with, press ENTER. This will put you in the Program editor. When you are in the Program editor, you will see the name of your program at the top line. To exit the Program editor and return to the homescreen, press 2nd and MODE.

Edit a Program

To edit a program, press the PRGM key to go back into the Program menu. This time, only press right > once. This will bring you to the EDIT menu. Scroll down to whichever program you want and press ENTER. This will cause the Program editor to open, with you being able to edit the program using a movable cursor.

When you are editting the program, you can add any commands or instructions that you want. A colon (:) denotes the beginning of each new line, and you can put multiple commands on a line by separating each command with a colon. Because multiple commands put together is typically wider than the screen, this will cause the line to wrap around to the next line.

You can also delete, overwrite, or insert commands and instructions. You move the cursor to whatever line you want, and then press DEL to delete an individual command or CLEAR to delete all of the commands on the line (leaving only the beginning colon); press DEL to also delete the line.

For overwriting commands, you simply select a command or type an instruction. The old command will be replaced with the new command. For inserting a new command, you press 2nd INS and either the space key several times for however many spaces you want or ENTER for a whole new line.

As editting programs involves a considerable amount of movement and scrolling, there are some shortcuts that make it easier. You can move the cursor to the beginning or end of a line by pressing 2nd < or 2nd >, respectively. You can scroll down or up with the cursor seven lines at a time by pressing ALPHA v or ALPHA ^, respectively. Use these shortcuts whenever possible.

Execute a Program

To execute a program, press the PRGM key to go back into the Program menu. This time, however, press right twice > > to get to the EXEC section. Scroll down to whichever program you want and press ENTER. This will cause the program's name to be printed on the homescreen. Press ENTER again and the program will be executed. The busy indicator will turn on while the program is executing.

Although you will usually let a program execute until it is finished, sometimes it is necessary to prematurely stop execution. For example, if you have a large program that takes a long time to execute and you don't want to wait. You can stop execution by simply pressing the ON key. After the ON key is pressed, the ERR:BREAK menu is displayed on the homescreen with one or two items.

The first item is 1:Quit. This item should be selected if you want to return to the homescreen. The second item is 2:Goto, and it appears if the program isn't edit-locked (Assembly programs can make the program not able to be editted from the Program menu). This item should be selected if you want to go to the line of code where program execution was halted.

When the calculator comes across an error while executing the program, it will give a similar error menu -- telling you what the error is and giving you the option to see where the error is in the program (if the program isn't edit locked). This allows you to figure out why it's producing an error. Many times it will be a simple mistake, such as forgetting to add the closing quotes or mistyping a command's arguments. However, sometimes the error will be much more sinister.

Copying & Renaming Programs

Copying and renaming programs is useful when you want to create a backup copy of a program you are working on (so all your hard work won't be lost in case you mess up the current copy or it gets erased somehow), or if you decide that you don't like the current name of your program and you want to give it a new name that you will be able to live with.

You first need to create a new program, following the steps listed above in "Create a Program". While in the Program editor to edit the program, you then press 2nd STO to get the Recall function to be displayed on the bottom line of the screen. Now go into the EXEC section of the Program menu.

After you select which program you want to use, the program's name is pasted to the right of the Recall function on the bottom line of the screen. When you press ENTER, all of the commands from the program you selected are pasted into the new program. You can then delete the old copy of the program, if you don't need or want it anymore.

In addition to pasting all of the commands into the new program, you can also just paste one or more commands. You simply create another copy of the program, and delete all of the commands and lines that you don't want. Don't try to rush deleting the commands and lines because you will just have to do it over. You then paste this program into the new program, and delete it afterward.

Memory Management

When you first get your calculator, it comes with everything set to the default settings: no programs, no applications, nothing. But after a while of using your calculator, you start to put programs on it, put applications on it, store functions in the Y= Editor, and even use the Stat Editor. Really, it just becomes a big, cluttered mess.

This may seem like a rather unimportant concern, but if you try creating or running a program, and you have other things on the calculator, the calculator may sometimes not have sufficient memory available. With all of the files floating around, taking up unnecessary memory, you were inhibited from using your calculator. The solution is to clean it up, which takes the form of two options: either delete or archive one or more of the files.

For both options, you should be in the Memory menu, which is accessible by pressing 2nd and MEM. You then select 2:Mem Mgmt/Del and press one to display a scrollable list of all the files on the calculator. You use the ^ and v keys to move the cursor on the left. On the top lines of the screen you will see how much free RAM and ARC (archive) memory there is.

Once you have found a file you want to delete, press DEL. If the file is not a variable, the calculator will prompt you to confirm the deletion, and you have to select 2:Yes. Once you have found a file you want to archive, press ENTER. An asterisk will appear to the left of the file name, indicating that it is archived. Archived files can't be editted (or executed, depending on what it is).

Archiving may sometimes not be possible, however, if the calculator is completely packed with files. This occurs primarily when a person can't bring themselves to delete a file because they feel like every file is important. At this point, the only option is to delete some files off of their calculator to make room. As part of memory management, a good policy is to keep the calculator's memory organized and to delete any files that you don't need.

Program Commands

If you want to add a command to your program, you will need to learn where the program commands are because you can't type the commands in. While in the Program editor (for editing your program), press the PRGM key. The menu that you saw initially is gone, replaced with three other menus:

There are lots of other menus on the calculator, as well. Two important menus are: the Test menu, reachable by pressing 2nd and MATH; and the Math menu, reachable by just pressing the MATH key. The most prominent menu, where you can find the majority of the commands, is the Catalog menu. To access the Catalog menu, press 2nd and 0.

You should familiarize yourself with where the commands are because it makes programming that much easier. After programming for a while, you will probably just internalize them. Also, for most of the commands, you can press the corresponding number on the menu to select that command or the first letter of the command to scroll to the first command with that starting letter.

Planning Programs

Before writing any of the code for a program, you should carefully plan out the program. This may seem like an unnecessary step, time that could be better spent, but it will pay major dividends in the end. Planning not only results in better quality programs, but many times it will also cut down the coding time (since you don't have to waste time rewriting the program) -- a win-win situation!

The first thing you want to do when planning programs is to detail the program functionality. Beginner programmers often say that they want to create a cool game, but they don't get much farther than that. For them to have a real chance of creating their program, they need to determine what the objective of the program will be, and then build off of that.

Once you have determined what the program will do, you need to decide what features the program will have. This can include: potential program options, the interface, an about screen, user help, and any other menus you want. The more thorough you are with planning your program, the easier the coding will be; it is to your benefit to do a good job.

If you can't come up with any ideas for your program or you are unsure of if the ideas that you have come up with make sense, you should get input from the TI community (I would personally recommend United-TI for the previous stated reasons). Since these are the people that are going to be primarily using your program when it is finished, you want to ask them to evaluate your program ideas and to offer some constructive criticism.

Translate It Into Pseudocode

The next step is turning the program plans into pseudocode. Psuedocode involves using English (or whatever language you speak) in place of the TI-Basic code to describe what the program will do to perform the desired functions and tasks. This prevents you from getting caught up in the TI-Basic syntax, allowing you to more clearly focus on the program.

You should first start by looking at the big picture of the program and then break it down into smaller and smaller details. Using an outline as the base, this means you would put the most important things first and then gradually add everything else. This allows you to mentally picture what the program is going to look like and to make sure you don't forget anything.

An important part of creating useful pseudocode is adding comments throughout. It is very easy to get lost in your logic or have problems come up that you don't have any idea on how to resolve. Besides telling you what the code is supposed to do (i.e. making coding easier), it will also force you to slow down and think through the logic of your program. Still, comments are only as good as you make them.