Calling One Program From Another - Texas Instruments TI-89 Manual Book

Ti ti-89: user guide
Hide thumbs Also See for TI-89:
Table of Contents

Advertisement

Calling One Program from Another

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
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.
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
. Because a subroutine must be defined before it can
Prgm...EndPrgm
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.
Declares the subroutine
as a local variable.
Defines the subroutine.
Calls the subroutine.
At the end of a subroutine, execution returns to the calling program.
To exit a subroutine at any other time, use the
A subroutine cannot access local variables declared in the calling
program. Likewise, the calling program cannot access local variables
declared in a subroutine.
commands are local to the programs in which they are located.
Lbl
Therefore, a
Goto
command in the calling program cannot branch to
a label in a subroutine or vice versa.
:subtest2(x,y)
:Prgm
: Disp x,y
:EndPrgm
Define
command with
: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
command.
Return
Chapter 17: Programming
287

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ti-92 plusTi-92 plus

Table of Contents