TI-92 Programming Conventions v1.1
Copyright 1997 Jeff Tyrrill
Distribute freely, unmodified
Last updated 5/10/97
In this document I have compiled some conventions that you can use in your TI-92 programs to make them easier to use for everybody. I use these in my own programs, and I would encourage others to do the same. These apply especially to games, but also to math and utility programs.
This document assumes knowledge of the programming environment; refer to the manual for help if you don't know what something is.
Folders
The TI-92 has the ability to store data and variables in multiple folders. Also, when programs are transferred to the computer via the Graph-Link, the folder is preserved. If a program only consists of one file, it should be put into the "main" folder. If it consists of many files, they should be in their own folder with the same name as the program. Also, the names of those variables should make them recognizable as from that program. This way, the user can rename the folder or move them into another folder. The user may just have a folder named "games" or "programs", which contains all their game files. The program should run from any folder.
Local variables (See note at end of document)
On the TI-92, local variables can be used in programs. These variables are deleted automatically when the program stops, and do not conflict with global variables (those which show up in Var-Link). Whenever possible, use local variables in programs. One disadvantage is that when one program calls another program as a subroutine, local variables from one program can not be used in another. In these cases, use global variables, and delete them with the DelVar command at the end of the program.
Functions v. programs
The TI-92 supports user-defined functions which can accept parameters and return a value. These can be used in mathematical expressions, as opposed to programs, which act like commands. Whenever possible, it is best to use functions. There are many programs in existence currently which perform mathematical operations and could easily be made into functions. If the author really wants it to have a GUI, they could include a program WITH the function, which provides the dialog boxes and calls the function to do the calculations.
Editlock
Variables and programs can be locked with VAR-LINK, so they cannot be accidentally edited. But, generally, there is no reason to do this in programs you distribute. It just annoys people who want to delete them, and if someone wants to edit them, they'll just unlock them.
Home screen and program I/O screen
Some programs clear the home screen. Remember, the home screen is different from the program I/O screen. Clearing the home screen clears all the last entries, and is not used for program output anyway. Don't have programs clear the home screen. Also, if a program displays output to the program I/O screen, such as generating a calendar or table, do not clear it when the program exits.
Graph screen and mode settings
This is a very important thing to have in your programs. It is easy, and very user-friendly. Most programs use the graph screen, or change mode settings in one way or another. (Remember, the current application is a mode setting.) If the program doesn't touch the graph screen, but might change mode settings, then include the following code in the beginning of the program:
Local modestr
getMode("ALL")\->\/modestr
At the end of the program, insert:
setMode(modestr)
Also, if the program will not function correctly in split-screen mode, add in the body of the program:
setMode("SPLITSCREEN","FULL")
Remember, all the split screen settings are stored in modestr, so the split screen will be restored automatically when the program ends.
If the program modifies the graph screen, insert the following code:
Local modestr,curgdb,funcgdb
getMode("ALL")\->\modestr
StoGDB curgdb
ClrGraph
setMode("Graph","FUNCTION")
StoGDB funcgdb
FnOff
PlotsOff
setGraph("Grid","OFF") ; if your program needs it
setGraph("Axes","OFF") ; if your program needs it
setGraph("Labels","OFF") ; if your program needs it
ClrDraw
setMode("SPLITSCREEN","FULL")
This sets up the graph screen for games, and puts it in Func mode. ALL SETTINGS, EVERYTHING, SPLIT SCREEN, 2 GRAPH MODE, THAT'S RIGHT EVERYTHING (except drawn objects) are restored when the program ends. To make it work, insert at the end of the program:
RclGDB funcgdb
RclGDB curgdb
setMode(modestr)
When the users go back to the graph screen after playing their game, everything will be perfect and untouched.
Teacher Key
This section applies only to games. Games should have teacher keys. After all, the only place most calculator games are played is in the classroom. A teacher key should be a single keystroke which works almost anytime, and it should exit the game and return to the home screen within a second or two. Two good choices for teacher keys are ESC, or 2nd-ESC.
Questions, comments? Email me
Revision History
1.1: Fixed a few typos, fixed mistakes in the Local Variables section where I accidentally and incorrectly advised on the use of global variables whenever possible and mistyped the disadvantages of local variables (sorry if this caused inconvenience)