Using subroutines -2-8, Using subroutines, K local variables – Casio ClassPad 300 PLUS User Manual

Page 533

Advertising
background image

20050501

Using Subroutines

Including the name of another program file inside of a program causes execution to jump to
the specified program file. The program that execution jumps from is called the “main
program”, while the program to which execution jumps is called a “subroutine”.
When program execution returns to the main program, it resumes from the point immediately
after the command that jumped to the subroutine.

Tip

• Note that any program can be a subroutine. The thing that makes any program a subroutine is

being jumped to from another program.

Main Program

Subroutines

Level 1

Level 2 Level 3

Level 4

Subroutines can be used in a variety of ways to help make calculations easier. Let’s say you
have a formula that needs to be calculated more than once in a program, or that needs to be
calculated by a number of different programs. Simply store the formula as a separate
program file (subroutine), and then you can jump to the program file that contains the
formula whenever you need it.

12-2-8

Creating a New Program

D

C

E

I

J

E ( )

I ( )

J ( )

A

D ( )

C ( )

k Local Variables

A local variable is a variable that can be created temporarily and used in a program. Use the
Local command to create a local variable.

Syntax:

Local

Ⅺ<variable name> (Ⅺ indicates a space.)

Example: Local abc

The above creates a local variable named “abc”.

Tip

• Local variables are deleted automatically after execution of a program is complete.

• Note that local variables are stored in their own special folder, so local variable names do not

affect the names of other variables in ClassPad memory. Because of this, you do not need to
worry if you assign a local variable a name that is already being used by another type of variable.

• Variables that are specified as parameter variables within a program are automatically treated as

local variables. Variables created with the Define command are also automatically treated as
local variables.

Advertising