Using variables in a program, Scope of variables – Texas Instruments PLUS TI-89 User Manual

Page 305

Advertising
background image

288 Chapter 17: Programming

17PROGRM.DOC TI-89/TI-92 Plus: Programming (English) Susan Gullord Revised: 02/23/01 1:14 PM Printed: 02/23/01 2:18 PM Page 288 of 40

Scope

Description

System
(Global)
Variables

Variables with reserved names that are created
automatically to store data about the state of the

TI

-89 / TI-92 Plus

. For example, Window variables

(

xmin

,

xmax

,

ymin

,

ymax

, etc.) are globally available

from any folder.

¦

You can always refer to these variables by using
the variable name only, regardless of the current
folder.

¦

A program cannot create system variables, but it
can use the values and (in most cases) store new
values.

Folder
Variables

Variables that are stored in a particular folder.

¦

If you store to a variable name only, it is stored in
the current folder. For example:

5

!

start

¦

If you refer to a variable name only, that variable
must be in the current folder. Otherwise, it cannot
be found (even if the variable exists in a different
folder).

¦

To store or refer to a variable in another folder,
you must specify a path name. For example:

5

!

class\start

After the program stops, any folder variables created
by the program still exist and still take up memory.

Local
Variables

Temporary variables that exist only while a program is
running. When the program stops, local variables are
deleted automatically.

¦

To create a local variable in a program, use the

Local

command to declare the variable.

¦

A local variable is treated as unique even if there is
an existing folder variable with the same name.

¦

Local variables are ideal for temporarily storing
values that you do not want to save.

Using Variables in a Program

Programs use variables in the same general way that you use
them from the Home screen. However, the “scope” of the
variables affects how they are stored and accessed.

Scope of Variables

Note: For information about
folders, refer to Chapter 5.

Note: If a program has local
variables, a graphed
function cannot access
them. For example:
Local a
5

!

a

Graph a

ù

cos(x)

may display an error or an
unexpected result (if a is an
existing variable in the
current folder).

Folder name

Variable name

Advertising
This manual is related to the following products: