TI-92 Programming Tips
Note the First: This page is incredibly old. And when I say old, I mean old. This general know-it-all attitude that goes on throughout it is definitely not something that I'd have written it with if I had written it today. Still, it is a handy reference, and the things that I show you are as applicable today as they were then. So, ignore the attitude, and read for the content.
A quick note: This page deals with the dialect of TI-Basic that is intrinsic to the TI-92 Graphing calculator.
A Few Hidden Things
Okay, let's turn on our calculators and get to the Home screen. Now, you may already know the trick for finding your calculator's ROM version; if you don't know, press F5 to get to the PrgmIO screen and then hit [Diamond]-(. You should get something like this:
Copyright (c) 1995 Texas
Copyright (c) 1995 Soft Warehouse, Inc.
Copyright (c) 1995 UJF-CNRS
Version 1.11 04/11/96
The actual screen looks like
(Your version number and date may be different).
Now you may already know how to get to the Debug menu by pressing S or Cos. But did you know, in all, that there are four ways to get to this menu? Including S and Cos, you can press Sin and [2nd]+(-) as well. Remember, if you choose to visit this menu, the line over your Status Bar will vanish and the only way to restore it is to reset your calculator. Also, I have found that performing this action will make your calculator's "OS" (?) unstable and more prone to crashing. With that in mind (if you're still brave enough), access the menu. You don't have to if you don't want to; I outline what is going on. All right, if you did this, you should see a menu with three choices:
(There are letters in front of each choice for selection, but I don't remember them).
RAM seems to be some kind of system check; performing it, however, will reset your calculator. INT ROM, I have no idea what it does and I would appreciate it if anyone knowing what it is will fire me an e-mail. RETURN, obviously, sends you back to your Home screen (I think).
All right, that's it for the Debug menu. There's one other thing that you can do from the Copyrights screen and that is press the P key. A list of the people who created the program for the calculator will pop up. P--Programmer, got it?
If you haven't figured out that [Diamond] + < , [Diamond] + > , and [Diamond]+ = gives you the actual mathematical symbols for <=, >=, and /=, then you aren't using this thing to it's full potential! There's one other hidden trick I've found in the Geometry app, but I'm leaving it up to you to find it. It's actually pretty useless. If you need a hint, it involves the Label tool and the arrow keys. OK, if you're not asleep by now, let's get on with the coding!
For Programmers Only
All right, let's crank up those Program Editors! These are some hints and tips that I think you will find quite useful as you do your programming thing, whether you are into graphics or text.
The TI-92 makes it very easy to transfer program control to another section of your program. Whether you use the ToolBar or PopUps, I've got a very interesting trick for you to try. I'm sure you have noted that variable names and labels use the same naming conventions. Variables, however, give you that interesting ability to "redirect", using the # operator you can create "files" or pass variables by reference (if they are global). What the TI-92 guide book doesn't tell you is that labels also share this property. Try plugging this program into your calculator:
InputStr "Enter 1 or 2", bar
Goto #("L" & bar)
Disp "You entered 1"
Disp "You entered 2"
As you see, if you enter 1 or 2, the program transfers control to the appropriate label. This property of labels is most useful with the PopUp instruction or with the DropDown instruction, since they place a value into a variable. You could then do as I did, using a generic label prefix and converting that value into a string. Of course, if you are a strong adherent to the practice of structured programming (I am too, don't worry), this technique may make your skin crawl. Well, I can't say anything to make you feel better, but you have to admit, this is a neat trick!
The Dialog...EndDlog block instruction that is provided with the TI-92 is an easy way to make your programs look more attractive and user-appealing. Note that I am not using the term "user-friendly", I do not because, I mean, come on, doesn't using a dialog seem much more appealing than using a command line interface? (Not that CLIs don't have their place, after all). However, it seems that they seem a little bit, well, static. After all, doesn't the Text command create static text? Well, I've found a way around this, using the when() function and a little ingenuity. The when() function is what I call an "embedded conditional," because that's what it is. You can use this function in Text arguments to modify the text string and make your dialogs seem like they are actually doing something. Note that you cannot see the results of what you did until you press the Enter key or you do something else in the program and return to that dialog. Here's some sample code that illustrates this:
Title "Test Dialog"
Text "The number is now " & when(num=1,"one",string(num))
DropDown "Number List",seq(i,i,1,5),num
Now, this is an incredibly simple example of this, but I believe it shows what I am talking about. Whenever you select the number one from the DropDown list, the Text command displays "The number is now one." If you select anything else, it shows the actual number. Besides using when() to do this, you can also simply connect values to other strings, kind of like a status box. Doing this is actually a great debugging tool if it isn't anything else. This code should give you a jumping off point for anything more ambitious you may want to undertake.
ll right, here we come to that age-old problem. Case sensitivity. If you are designing a program that uses a command line interface (not UNIX-like, that is) or requires input from the user that must be processed without worries from this, then you need some custom functions. You can slave over a hot Editor and create them yourself, but if you are not at all familiar with the character set that the TI-92 uses, then you are pretty much dead in the water. Never fear, here I am. Now you can download the convup() (Convert Uppercase) function from me and use it without ever knowing how the heck it works, or you can whip out your notepad...err...fire up your printer and LEARN!
All right, students, are we listening? Okay, here's the source:
t & char(when(c<97 or c>122,c,c-32))->t
This function takes one argument, which is the string that you want to uppercase. Now, all of you astute observers out there may notice that there is no expression on the line before the EndFunc directive. Why doesn't this cause an error? Well, look on the line above EndFor. The store command that is executed there returns a string expression, doesn't it? The current value of t, am I right? Therefore, you are tricking the TI into thinking that you have done everything correctly. The function iterates through every character in the string, checking to see if its "TI-ASCII" (hee,hee!) code is less than 97 or greater than 122. Why those magic numbers? Because they are the codes of the lowercase letters A and Z. If it is, leave it alone; if it isn't, subtract 32 and attach it. Subtracting 32 from the code of a lowercase letter uppercases it. Simple, eh? Now that you know how it works, Gentle Programmer, you can now try to top the teacher. Try to optimize it. If you can, well, you know my address. Have fun!
Storing Your Data
A problem with the TI-92 is that it doesn't give a really flexible way to store and access data. Sure, you can use data variables, but you cannot access them relatively easily. However, I have managed to get past that and found an effective way to work with data variables. Now, usually I give you some source to look at as I discuss a topic, but in this case you are going to have to download a ZIP file containing the three programs I will be using as examples. These programs are addbook(), qfilter(), and qreport(). I will only be discussing AddBook and QReport, however. QFilter is somewhat of a toy to play with in my opinion. Addbook is the data entry component, and QReport is the data retrieval component.
>If you run AddBook and begin work with it, you will see that there are pre-defined fields for it. A basic flat-file database system. If you peek at the source (Please peek!), you will notice that I use the NewData instruction quite uniquely. If a boolean flag ("nf" [new file]) is equal to 1 then create the database with the current lists. Otherwise, take the current lists and append the new lists to them using augment() and create the new data variable. This is the only way to change the contents of a data variable from a program, you cannot, I repeat, cannot, use the store instruction!
Now, QReport (QuickReport), retrieves information and makes it look a bit more appealing (Sure, you could look at the file using the Data/Matrix Editor, but who would want to?). If you look at the source, you can see that it first retrieves the first column/list from the data file (The "Names" field) and uses that as one of the arguments in the DropDown instruction. Once you make your choice from the list, the program snaps into action. It extracts the pertinent fields from the data file based on the value returned by DropDown and assembles them into a dialog, then it displays the dialog with the title "REPORT." It isn't quite as complicated as AddBook, well, actually neither program is really complicated. I'm sure you could understand them if you took the time to study the code. Armed with that knowledge, you will be ready to do some heavy-duty data manipulation (well, as much as the TI-92 allows).
Some Tricks for the Graph Screen
I call this section "Some tricks for the Graph Screen," but it is actually a collection of some rules of thumb you should use when you are working with items on the graph screen. For example, ever try to get PxlText text exactly right, but you have to do a lot of pixel-pushing in order to do it? It isn't as tough as it seems if you remember a few things. One, each character is 8 pixels in height. So, if you want to place two lines of text on top of one another, you'd do something like this...
PxlText "Line one", 0,0
PxlText "Line two", 9,0
This construct cleanly separates these two lines of text with one row of blank pixels. Also, each character is 6 pixels in width. However, I have had some problems applying this rule effectively, so I really don't have any good source to back it up. Sorry.
If you are one of those people who absolutely must use the Pt- commands in a program, then take heed. Using these commands has a slight snafu: you must know how they are going to behave. The only really effective way of knowing is to use pixels. How do you use pixel coordinates? With a conversion formula, of course! The TI-92 guidebook gives you a formula in one of its code examples (In the section on the ClrErr command), but it is a formula that converts from Rectangular coordinates to Pixel. It looks like this:
Δx * pxlCol + xmin = xcoord
Where Δx is the distance from one pixel to the center of the next, pxlCol is the pixel coordinate of the column you wish to use, xmin is the xmin system variable, and xcoord is the resulting x coordinate. You can substitute Δy, pxlRow, ymin, and ycoord and get the corresponding y coordinate.
Now, to do the other way around, that is, convert point to pixel, you use this formula>
(xcoord - xmin) / Δx = pxlCol
for columns and this formula
| ( ( ycoord - ymin) / Δy ) - 102 | = pxlRow
for rows, where the bars represent the abs() function, of course. My pictools() suite of programs illustrates these formulas in the PicMaker module, where a matrix for use in a NewPic command is generated from an existing picture. Try out my PicTools programs! You might like what you find! I am especially proud of my PicPlot program, which displays a grid in which you draw pictures by filling in the blocks. The program is about 4K on the calculator, so make sure you have space. The PicZoom program contains code which I'm going to discuss at a later date.
Here are some bits of information that you may find useful as you do your TI Programming:
When using the Disp command, remember that the screen is 40 characters wide.
The Text command uses up to 34 characters in a line and you can use up to 10 of them in one Dialog block (this is true with all of the Dialog components).
If you place embedded carriage returns (char(13)) into a string variable, they show up when you preview the string using the Var-Link screen.
The exact center of the Graph and Output screens is Row 51, Column 119.
You can generate program code from strings using expr() (The PicMaker program illustrates how to do this).
Remember, locking your files is the easiest way to protect them.
Indirection is your best friend.
This page was last modified on Oct. 6, 2012.