Programming a TI-85 Graphing Calculator – Revisting the 1990’s TI-BASIC

In my previous post, I discussed how I cleaned out and restored my old TI-85 Graphing Calculator after finding corroded batteries inside.

After finally getting it to turn on, I immediately started reliving my high school experience. It was honestly kind of surprising how quickly my memories came back to me. Despite not using the calculator for almost two decades, I was able to remember and use many of the functions and my fingers seemed to instinctively know where each letter was on the keyboard. Maybe it shouldn’t have been surprising though, that thing was an extension of my arm during many classes in high school and college and I spent a lot of free time reading the manual and learning the simple programming language that came pre-installed. (ProTip: This is not how you become popular in 1995.)

I had gotten the calculator out of storage to see if any of my old high school programs were still installed. Unfortunately, the TI-85 did not come equipped with permanent storage so programs needed power to survive in RAM. Mine were all lost.

I was probably feeling overly nostalgic because I started working on a new program for the calculator. Appropriately enough for a calculator, my program is called Simple Math. It takes two numbers and then adds, subtracts, multiplies, or divides them. Obviously, this is a bit redundant to the calculator’s basic functions. I was more interested in working with the TI-BASIC programming language than I was with creating something useful.

The TI-85 was limited to just 8 characters for the names of variables, functions, and files (as were most of computers of that era). So the program is actually called SMPLMTH. When loading it up from the Programs menu, this is what you see.

The Simple Math input screen

The program has a greeting and then asks for two numbers. The TI-85 has two methods of asking for user input. The first (and the one I’ve used here) is the Input command. It simply displays a question mark and then waits for the user to type in a value.

An example of the code for Simple Math

The second method is using a Prompt command. This is very similar except that the name of the variable being loaded is displayed for the user.

Using the Prompt function in a simple program on a TI-85

After the user enters the numbers, the program displays the chosen numbers and then asks which mathematical function should be applied.

Imagine a calculator program that can do all of this?

The TI-85 cannot concatenate strings and numbers so the line displaying the chosen numbers was fairly difficult to figure out. To be used in a sentence, the variables containing numbers had to be cast as strings. In modern programming languages, there are simple commands that can easily cast values to other data types, but not so on the TI-85. For example, in Excel, you would use the TEXT function to convert numbers to strings. (Although many can do it implicitly, including Excel. The TEXT function in the example below is not necessary to get the same result.)

Casting number values as text in Microsoft Excel.

To accomplish it on the TI-85, I needed to use a special function called St⯈Eq (String to Equation). It wasn’t as simple as just dropping the variable into the function. I ended up needing to do a Linear Regression on the variable and then substring the result into a new string variable. (I can’t take credit for the idea, I found the code on That’s obviously needlessly complex but I think it was the only solution available.

It also highlights one of the major difficulties of writing TI-BASIC – the use of non standard characters. Converting strings required the Eq⯈St command. Storing a value to a variable requires another arrow character. For example, 60 → VarName. This is significantly different from other version of BASIC which used the LET command (ie. LET VarX=95). The arrow assigning values reminded me a little of the R syntax, although that can easily be typed with a keyboard (i.e. VarX <- 60).

A few of the special arrow characters on the TI-85

I’m using a unicode arrow characters (U+2bc8 and U+2192) to replicate the look of these characters, but I have no idea what the characters actually are. They definitely make programs harder to write since you can’t use a regular text editor. As I recall, to write programs for a TI-85, you needed to use their TI-GRAPH LINK software. It was a very proprietary model.

Once you entered your numbers and made your calculation choice, the Simple Math program used an IF statement to determine which function to perform and output the result.

The final output of the Simple Math program

Despite the program being pretty useless, it was interesting to work in such an old environment and think about what has changed and what has remained the same in the years since I last used it.

Some functions like IF statements are very similar to their modern equivalents (although I needed to nest the IF statement to have multiple conditionals). Other things, like the lack of local variables were surprisingly different. (The variables that I used in the program were automatically global and accessible by any other program or calculation.) Even in this little program I was able to find several examples of increased efficiency and simplified syntax in modern programming languages.

Using the NUMA global variable outside of the Simple Math program.

It was also interesting to think about the possibility that I might be one of the only people in the world to write a program for this particular piece of hardware in 2019. Although that might not be true because the internet still has a surprising amount of resources of programming older TI graphing calculators. Perhaps there are more hobbyists out there than I realize. has a ton of programs, examples, and guides for the TI-85
TI-Freakware has a guide to TI-BASIC for the TI-85.
TI-Basic Developer has a ton of guides and programs available (although apparently for later TI versions)
Wikibooks has a TI-Basic manual, but once again it seems more focused on later calculators. (I found a few commands that are not compatible with the TI-85.)
The University of Arizona maintains a website of TI-85 lessons.

The TI-85 is a bit of a relic now. Between the monochrome screen, tiny amount of memory, difficulty of transferring data and programs, and non-standard characters, it is hard to think of a compelling reason to use it today. Making kids learn coding on this in the age of languages like Scratch and Python would be needlessly difficult. However, playing around with it for an evening reminded me of what a remarkable piece of technology this was. Decades before anyone had conceived of a smartphone, millions of high school kids carried a programmable computer in their backpacks that wasn’t that much bigger than a modern larger smartphone (at least in length and height, not so much in terms of width).

Size comparison of a TI-85 and a Google Pixel 2 XL

Unfortunately I am not able extract my example program off of the calculator. I’ve long ago lost my graph-link cable and even if I had it, my computer doesn’t have a DE-9 connector. Also, the Graph-Link software for the TI-85 doesn’t support versions more recent than Windows 95.

If you’d like to see the program, I’ve typed up the code below. The variables NUMA and NUMB hold the numerical values (REAL type in TI-BASIC) and NUMAS and NUMBS are the String versions. It is released under the MIT License.

:Input NUMA
:Input NUMB
:Linr {0,1},{NUMA,NUMA
:sub(X,1,lngth X-3 → NUMAS
:Linr {0,1},{NUMB,NUMB
:sub(X,1,lngth X-3 → NUMBS
:Disp "1. ADD"
:Disp "2. SUBTRACT"
:Disp "3. MULTIPLY"
:Disp "4. DIVIDE"
:Input ANS1
:If ANS1 == 1
:If ANS1 == 2
:If ANS1 == 3
If ANS1 == 4
:Disp round(NUMA/NUMB,2)

Additional Examples of Nested If Statements

In my previous post, I discussed an issue in Scratch relating to Nested If statements. I think that by limiting the If statement to only one conditional (an If condition or an Else condition), the concept of multi-conditional statements has been made more difficult that it should be. I believe that Nested If statements are more complicated for a beginning programmer to understand than Else If statements.

I thought I’d take a look at how a few other programming languages have handled multi-conditional statements.

There’s an alternative to Scratch called Snap! designed by UC Berkeley. (It’s actually based on Scratch and looks very similar.) The language has less focus on being immediately intuitive and extends Scratch with blocks that handle several advanced programming concepts.

I used Snap! to write the same basic emoji program that I created in Scratch. Using the basic available blocks, it looks very similar. To use multiple If statements, I had to nest them inside the previous Else statement.

I did like one difference that stood out from Scratch. The nested Ifs were automatically set in alternating shades to make them stand out. This increased the readability and made it a little easier to understand what was going on.

Snap! is designed both to teach younger children and adults programming concepts. There are a few additional blocks in the base version of Snap! that you won’t see in Scratch, but it also comes with several libraries that add even more complexity and advanced techniques. The library “Multi-branch conditional (switch)” allows (as the name implies) multiple conditionals in an IF statement. It adds several new commands to the Control blocks. One of them is a cases block that allows for multiple else if statements to be added.

Else If built in Berkeley’s Snap language

The black arrows in the bottom right add or subtract spaces to insert more Else If statements. The final statement can be used for an Else block that runs if none of the other Else If blocks run. The syntax and visual layout takes a little getting used to, but I do like this better than nesting all the If statements inside of each other.

Another language that people encounter early in their programming careers is the cell formulas in Microsoft Excel. Up until recently, multiple If statements needed to be nested within each other, similar to Scratch. I’ve spent many years in my career writing overly complicated formulas like this.

Nested If Statements in Excel

The commas dividing the IFs and the stack of closing parentheses at the end make the typo potential high and the readability low. Thankfully, in newer versions of Excel (and Google Sheets), there is a function called IFS which handles multiple conditionals much more smoothly.

The IFS method of handling multiple if statements.

The format of this is IFS(Condition 1, Result 1, Condition 2, Result 2, Condition 3, Result 3 and so on. The result for the first condition that is true will execute. There isn’t a default ELSE, so to replicate that functionality you can just add the word TRUE as the final condition check. If none of the previous conditions were met, that one one will always execute.

Finally, it worth mentioning that many other programming languages have a command called Switch or Case. (You may have noticed that the multi-conditional block in Snap! is called cases.) Functionally, this behaves much the same as an ELSE IF. A series of cases are evaluated and only the one that matches a condition is executed. Here is an example of the emoji program written in JavaScript with a Switch.

JavaScript Switch Example

The syntax here shows a key difference from the ELSE IF logic. 1.) There is no comparison operator (===, >=, etc) required – it is assumed by default. The switch statement takes a variable or value and then compares it with each of the cases. 2.) Unlike an IF statement, the program will evaluate all cases even after finding a match. To prevent this, the break keyword is included in each case result. When encountering a break, the program will move on to whatever follows the switches final curly bracket. 3.) The default keyword functions in the same way as the terminating ELSE in and IF statement. This will run if none of the other cases were met.

Some programmers prefer to use IF statements for comparison operators such as equality or greater than or equal to. Switch is often used for checking the value of strings, as in the emoji code above. For example:

if(Variable1 >= Variable2) {
  console.log("The first number is higher");
} else {
  console.log("The second number is higher";)

switch(Variable1) {
  case "Breakfast":
    console.log("Good morning!")
  case "Lunch":
    console.log("Good afternoon!")
  case "Dinner":
    console.log("Good evening!")
    console.log("Good day!");

Honestly, the choice of using an IF THEN ELSE or a SWITCH comes down at least partially to programmer preference. There is some speed variability between the two methods that can be analyzed if optimization is needed, but generally speaking, either method can be used for both of the above situations.

Regardless of which methodology is used, the multi-branched conditional statement is an important concept for new programmers to learn. The nested if statements in Scratch can work for simple projects, but for more advanced work, programmers will need to learn improved techniques.

Nested If and Variable If Statements in Scratch

I love using Scratch to teach children and others about coding. By using blocks instead of syntax, it has simplified coding to make it accessible even for very young children. I love that it has eliminated the need to learn some of the more difficult aspects of coding such as where curly brackets and parenthesis go when a person is first learning about things such as variables, control flow, and loops.

There are a few areas where I wish Scratch hadn’t simplified quite so much. I understand the need to keep things simple for young learners, but in some cases, over simplification inadvertently leads to more complex situations. The primary example of this is the limitation of the IF THEN ELSE to only one ELSE statement.

For those not familiar, the IF THEN ELSE statement is used to control which parts of the code run based on variable conditions – often times input from the program’s user. (This is called a conditional logic or control flow.) The programmer can put in several alternate pieces of code – which one runs depends on the values currently in the program. For example, if a number is greater than 50, then the program will say it is a big number. Else, the program will say it is a little number.

Example of an IF statement in Scratch

The problem is that programs often have more than two alternatives that might need to run. There could be three, ten, or even a hundred alternatives. In most programming languages this is handled with an ELSE IF statement (or alternatively a SWITCH statement). If the first condition is not met, the program will check the next one. If that one is not met, it will continue checking down the list until a condition is met or it reaches the end of the list.

To illustrate this, I’ve written a simple program that has four conditions. The user is asked to enter a letter. A different emoji is returned for each letter – including a sad face in case none of the requested letters was used.

Here is the program in a language called JavaScript. The variable emoji contains the user input. The first IF is just written with “if” but each subsequent one is written as “else if”. Finally, an “else” catches anything that didn’t match earlier.

Here is the same example in a language called Python. This one uses the slightly more hard to read syntax of “elif” which is short for “else if”.

This syntax is clean and easy to read. You can follow the logic easily and determine what will happen based on the value of the variable.

Unfortunately, Scratch lacks the ability to have multiple conditionals in a single IF statement. There is a workaround called the Nested If statement. Essentially, this is just a regular IF THEN ELSE statement, however, instead of putting something like a message to be displayed to the screen in the ELSE, you put another IF statement. This can be repeated over and over again until you have all your conditionals. This can get very complicated very quickly.

Here is the same program written in Scratch. Notice how each ELSE statement has another IF THEN ELSE statement inside.

Scratch Nested If Example

What if you want to add more letters and emojis to the code? To add another condition into the logic flow, you drag a new IF statement into the ELSE statement of the last IF statement. This can be repeated as often as needed.

While not problematic at first, it can become overwhelming in short order. In this example, we display a separate emoji for letters A through H. (Also out sad face is displayed if none of those letters were used.)

Look at the bottom of this code block – there are 8 block closures all in a row. Imagine if we had an emoji for all 26 letters!

This can be very confusing, especially for younger children learning to code. It’s also a fairly archaic way to code – more reminiscent of programming languages from the 80s then those of today.

This has been discussed in Scratch forums in the past but does not seem to have generated much interest.

Other block languages have added this functionality in a very eloquent way. Here’s an example from Microsoft’s MakeCode. The user simple clicks the plus sign at the bottom of the block to add a new else if statement.

To keep things a little easier to read (like the MakeCode example), I like to use an alternative method for keeping track of multiple IF statements. I use a variable to track if an IF Statement has been used, which allows me to keep the various IF statements separate. This is quite a bit easier to read.

Here is the original program again, but now using a variable (emojiCheck) instead of multiple nested IF statements.

The emojiCheck variable is initially set to zero but if any of the IF conditions are met, it is changed to one.

The final IF statement checks for the value of emojiCheck. If it’s zero, that means that none of the previous IF conditions were met and the sad emoji face is displayed. If any of the previous IF statements were met, this block does not execute.

It is not perfect, but I think this Variable If method may help new users learn the code without the confusing aesthetics of a nested if statement.

All of the code in this example is available to those interested.
Emoji Code Examples
The Scratch programs are also shared with additional comments included in the code.
Nested If example in Scratch
Variable If example in Scratch

Edit: I added a few more examples from other programming languages in another post: Additional Examples of Nested If Statements.