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 Technicalc.org.) 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.
ticalc.org 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.

PROGRAM:SMPLMTH
:ClLCD
:Disp "WELCOME TO"
:Disp "SIMPLE MATH!"
:Disp "ENTER A NUMBER"
:Input NUMA
:Disp "ENTER ANOTHER NUMBER"
:Input NUMB
:Linr {0,1},{NUMA,NUMA
:Eq⯈St(RedEq,X
:sub(X,1,lngth X-3 → NUMAS
:Linr {0,1},{NUMB,NUMB
:Eq⯈St(RedEq,X
:sub(X,1,lngth X-3 → NUMBS
:ClLCD
:Disp "YOU CHOSE "+NUMAS+" AND "+NUMBS+"."
:Disp "WOULD YOU LIKE TO:"
:Disp "1. ADD"
:Disp "2. SUBTRACT"
:Disp "3. MULTIPLY"
:Disp "4. DIVIDE"
:Input ANS1
:If ANS1 == 1
:Then
:Disp NUMA+NUMB
:Else
:If ANS1 == 2
:Then
:Disp NUMA-NUMB
:Else
:If ANS1 == 3
:Then
:Disp NUMA*NUMB
:Else
If ANS1 == 4
:Then
:Disp round(NUMA/NUMB,2)
:Else
:Disp "THAT WASN'T A CHOICE!"
:End:End:End:End

TI-85 vs Potassium Carbonate: A Cautionary Tale

This year at the R Studio conference, I heard an excellent presentation from Mary Rudis on teaching statistics with R at community colleges. (I don’t teach at that level, but enjoy learning more about education techniques.) She mentioned in her talk that many students get their start in stats programming using graphing calculators.

This comment was just an aside, but it got me thinking about my own programming history and some of the early programs I wrote on my TI-85 graphing calculator when I was in high school and college to help calculate equations in my science and math classes. For example, I remember writing a simple program where you could enter the mass and distance of two objects and it would calculate the gravitational force.

I came home from the conference feeling nostalgic about my early programming work. I wanted to see if any of my old programs were still saved on my calculator. I dug it out of a storage bin and opened up the back panel to put in some batteries. Unfortunately, there were already batteries in there…

Potassium Hydroxide forming a Potassium Carbonate salt around the seal of the battery. (Note, be smarter than me and don’t handle them without gloves.)

I don’t remember what year those batteries were installed, but they expired 16 years ago. At some point, they leaked their internal potassium hydroxide, which forms a salty crystal called potassium carbonate once outside of the battery. The inside of the battery compartment and several of the springs were caked in the stuff. (This is a skin irritant, a fact I discovered when I picked up the batteries. You should wear gloves when handling leaky batteries.)

Potassium Carbonate salt around the springs in the TI-85 battery holder.

Using a Q-Tip dipped in white vinegar, I was able clean out the area. Vinegar is a mild acid so it neutralizes the strong base of the potassium carbonate. I tried hard to avoid leaking any liquid inside of the calculator.

After giving the calculator some time to dry out, I loaded it up with fresh batteries and crossed my fingers.

The TI-85 graphing capabilities.

It powered right up! All the buttons and the screen seem to work fine. Thankfully, I haven’t noticed any adverse performance effect at all.

I was sad to realize that the TI-85 did not have any form of permanent storage. (It was created in the days of the 3.5 inch floppy disk, after all.) All the variables, programs, and custom functions are stored in memory – which required power to maintain. The calculator had a backup coin cell battery (to preserve power when changing the AAA batteries) but that had long since expired as well. Whatever programs I had written had long ago been erased when the calculator ran out of power.

Despite losing all that early work, it’s been surprisingly fun to have this piece of my teenage life back. I’ve done some simple graphing and even written a small program. (More on that later.)

It was a good reminder to always remove the batteries from electronics that are not going to used for awhile. I was lucky that the leaked batteries didn’t cause any damage to the calculator. The TI-85 may have escaped this battle unscathed, but leaking batteries can cause irreparable damage to electronics. Don’t do what I did and let them sit for over a decade in storage.

Edit: I’ve added a new post about programming the TI-85.