[7.47] Global Variables Not Evaluated When Local Variable Has The Same Name; [7.48] Create Functions In Programs - Texas Instruments TI-89 Tip List

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

Advertisement

After exiting tooltab(), I just press [CUSTOM], and my menu is restored. Note that I use the folder
specifier main\, so custom92() is executed regardless of which folder from which tooltab() is executed.
If you would rather not use this feature, just call tooltab() with an empty string:
tooltab("")

[7.47] Global variables not evaluated when local variable has the same name

Unexpected behavior can result when global variable names are used as input in a Request statement.
If the program has defined a local variable of the same name, the global variable will not be evaluated.
This situation arises, for example, when you use global variables to save floating-point numbers. The
program below demonstrates:
t()
Prgm
local x
clrio
dialog
request "x",x
enddlog
expr(x)→x
disp "x is",x
EndPrgm
Expected operation ensues if you supply a number for x at the Request prompt. For example, if you
enter 4.22 at the prompt, then the Program I/O screen shows
x is
4.22
However, suppose you have previously stored the value 4.17723887656 to a global variable x, for use
in this program. To avoid re-typing the value, you just enter x at the prompt. In this case, x is not
evaluated, and the Program I/O screen shows
x is
x
A work-around is to use unusual local variable names, in the optimistic hope that the program's user
will not have a global variable of the same name. Characters from the International sub-menu of the
CHAR menu may be appropriate.

[7.48] Create functions in programs

Creating functions in a program is straightforward, as long as you really define them as functions and
not expressions. For example, suppose we have created this function
chi(a,x,b)
Func
when(x>a and x<b,1,0)
EndFunc
and we want to use it to create a function g(x) of the form
7 - 62

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ti-92+

Table of Contents