690
Programming
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.
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
For...EndFor
loop (which is
discussed later in this module). The variable
i
is the loop counter. In most
cases, the variable
i
is used only while the program is running.
À
Declares variable
i
as local.
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
Undefined
variable error message displays when you evaluate a user-
defined function or run a user-defined program that references a local
variable that is not initialized (assigned a value).
For example:
À
Local variable
m
is not assigned an initial value.
©
(
p
/4)
&
maximum
maximum
©
Local i
À
For i,0,5,1
Disp i
EndFor
Disp i
Define fact(n)=Func
Local m
À
While n>1
n
¦
m
&
m: n–1
&
n
EndWhile
Return m
EndFunc
Summary of Contents for TI-Nspire
Page 38: ...26 Setting up the TI Nspire Navigator Teacher Software ...
Page 46: ...34 Getting started with the TI Nspire Navigator Teacher Software ...
Page 84: ...72 Using the Content Workspace ...
Page 180: ...168 Capturing Screens ...
Page 256: ...244 Embedding documents in web pages ...
Page 336: ...324 Polling students ...
Page 374: ...362 Using the Review Workspace ...
Page 436: ...424 Calculator ...
Page 450: ...438 Using Variables ...
Page 602: ...590 Using Lists Spreadsheet ...
Page 676: ...664 Using Notes You can also change the sample size and restart the sampling ...
Page 684: ...672 Libraries ...
Page 714: ...702 Programming ...
Page 828: ...816 Data Collection and Analysis ...
Page 846: ...834 Regulatory Information ...
Page 848: ...836 ...