Using Local Variables - Texas Instruments TINSPIRE Manual Book

Teacher software guidebook
Hide thumbs Also See for TINSPIRE:
Table of Contents

Advertisement

Note: Displaying a result with or does not store that result. If you
expect to refer later to a result, store it to a global variable.
©
(
/4)
maximum
p
&
maximum
©

Using local variables

A local variable is a temporary variable that exists only while a user-
defined function is being evaluated or a user-defined program is
running.
Example of a local variable
The following program segment shows a
discussed later in this module). The variable
cases, the variable
Local i
À
For i,0,5,1
Disp i
EndFor
Disp i
À
Declares variable
Note: When possible, declare as local any variable that is used only
within the program and does not need to be available after the program
stops.
What causes an undefined variable error message?
An
variable error message displays when you evaluate a user-
Undefined
defined function or run a user-defined program that references a local
variable that is not initialized (assigned a value).
For example:
Define fact(n)=Func
À
Local m
While n>1
n
m
m: n–1
¦
&
&
EndWhile
Return m
EndFunc
À
Local variable
690
Programming
i
is used only while the program is running.
i
as local.
n
m
is not assigned an initial value.
loop (which is
For...EndFor
i
is the loop counter. In most

Advertisement

Table of Contents
loading

Table of Contents