■Subroutines
A program contained in a single program area is called a “ main routine” .
Often used program segments stored in other program areas are called
“subroutines” .
Subroutines can be used in a variety of ways to help make calculations easier.
They can be used to store formulas for repeat calculations as one block to be
jumped to each time, or to store often used formulas or operations for call up as
required.
The subroutine command is “ Prog” followed by a number from 0 through 9 which
indicates the program area.
Example Prog 0 Jump to program area 0
Prog 2 Jump to program area 2
After the jump is performed using the Prog command, execution continues from
the beginning of the program stored in the specified program area. After execu
tion reaches the end of the subroutine, the program returns to the statement fol
lowing the Prog n command in the original program area. Jumps can be performed
from one subroutine to another, and this procedure is known as “ nesting” . Nest
ing can be performed to a maximum of 10 levels, and attempts to exceed this
limit will cause an error (Ne ERROR) to be generated. Attempting to use Prog
to jump to a program area in which there is no program stored will also result
in an error (Go ERROR).
*A Goto n contained in a subroutine will jump to the corresponding Lbl n contained
in that program area.
Example Simultaneously execute the two previously presented programs
to calculate the surface areas and volumes of a regular octahedron
and tetrahedron.
Express the result in three decimal places.
This example employs two previously explained programs, and the first step is
to input the specified number of decimal places (W f7l3).
- 1 2 7 -