EasyManua.ls Logo

Texas Instruments TI-89 - Calling One Program from Another

Texas Instruments TI-89
623 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Chapter 17: Programming 287
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 287 of 40
To call a separate program, use the same syntax used to run the
program from the Home screen.
:subtest1()
:Prgm
:For i,1,4,1
: subtest2(i,i
ù
1000)
:EndFor
:EndPrgm
To define an internal subroutine, use the
Define
command with
Prgm...EndPrgm
. Because a subroutine must be defined before it can
be called, it is a good practice to define subroutines at the beginning
of the main program.
An internal subroutine is called and executed in the same way as a
separate program.
:subtest1()
:Prgm
:local subtest2
:Define subtest2(x,y)=Prgm
: Disp x,y
:EndPrgm
:
¦
Beginning of main program
:For i,1,4,1
: subtest2(i,i
ù
1000)
:EndFor
:EndPrgm
At the end of a subroutine, execution returns to the calling program.
To exit a subroutine at any other time, use the
Return
command.
A subroutine cannot access local variables declared in the calling
program. Likewise, the calling program cannot access local variables
declared in a subroutine.
Lbl
commands are local to the programs in which they are located.
Therefore, a
Goto
command in the calling program cannot branch to
a label in a subroutine or vice versa.
Calling One Program from Another
One program can call another program as a subroutine. The
subroutine can be external (a separate program) or internal
(included in the main program). Subroutines are useful when a
program needs to repeat the same group of commands at
several different places.
Calling a Separate
Program
Calling an Internal
Subroutine
Tip: Use the Program
Editor’s
Var
toolbar
menu to enter the
Define
and
Prgm...EndPrgm
commands.
Notes about Using
Subroutines
:subtest2(x,y)
:Prgm
: Disp x,y
:EndPrgm
Defines the subroutine.
Declares the subroutine
as a local variable.
Calls the subroutine.

Table of Contents

Other manuals for Texas Instruments TI-89

Related product manuals