Texas Instruments TI-89 Tip List page 34

Graphing calculator
Hide thumbs Also See for TI-89:
Table of Contents

Advertisement

Source code description
The source code for ruler() is shown on the following pages. I have added comments to describe the
operation, but these comments are not in the program in the tlcode.zip file.
ruler() uses local programs and functions so it can be distributed as a single program. This does
require using global variables to pass parameters, since the scope of local variables defined in ruler()
does not extend to the other locally-defined programs. The global variables are stored in the main\
folder, since it is guaranteed to exist on every calculator, and they are deleted before exiting ruler().
Since ruler() needs to change the Graph and Mode settings, they are saved in the beginning of the
program and restored at the end. The Angle mode is set to Radian, so I know that the results of angle
calculations are in radians. To change the Graph and Mode settings, I use the numeric string
arguments for setGraph() and setMode(), instead of the text strings. This makes program operation
independent of language localization.
I want the graph screen clear except for the cursors, so this code completely clears and displays the
graph screen:
ClrDraw
ClrGraph
PlotsOff
FnOff
SetGraph("3","1")
SetGraph("4","1")
DispG
To avoid writing, distributing and maintaining two versions of the program, I detect which calculator
model (TI-89 or TI-92 Plus) on which the program is running. The model is determined by using
getConf() to find the calculator screen width. If the width is 240, then the calculator is a TI-92 Plus,
otherwise it is a TI-89. The expression to find the model is
if getconfg()[dim(getconfg())-14]=240 then
...
The test returns true if the calculator is a TI-92 Plus. getConfg() returns a list of configuration pairs. The
location of the screen width configuration pair depends on whether or not certificates are installed.
However, the screen width is 14 elements from the end of the list, regardless of certificate installation,
so the expression gets the configuration with respect to the end of the list, that is, 14 elements from the
end.
Three specific parameters depend on the calculator model: the screen size, the key codes for some
keys, and the pixel pitch. I account for all these parameters by assigning the correct values to variables
based on the calculator model, then the program logic uses these variables instead of hard-coded
constants.
I use the letter keys [O], [M] and [H] for features in ruler(). The same keys are used for both the TI-89
and the TI-92 Plus. However, on the TI-89, I don't make the user enable alpha mode to press the right
key. Instead, I test for the unmodified key code for that letter key. For example, the [O] key is the same
as the [-] key, so I just test for the [-] key code (45), instead of the [O] key code (79). The TI-89 user
presses the [-] key to perform the origin/target toggle function.
The user can press any of three keys to exit the program: [ESC], [QUIT] or [HOME]. This just makes it
easier for the user, since she does not need to remember exactly which key stops the program. The
cursor movement keys are consistent with the standard operation on the Graph screen. Pressing just
© Clear all plots, functions and drawings
© Turn grid off
© Turn axes off
© Display graph screen
1 - 23

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ti-92+

Table of Contents