Re: TI85 Programs - anything like GOSUB?


[Prev][Next][Index][Thread]

Re: TI85 Programs - anything like GOSUB?



On Wed, 9 Oct 1996, Webster wrote:


> Is there any command (okay I know there isn't a command for this) or a
> way to fake a gosub statement in a TI-85 basic program?
What you have to do is write the subroutine as a separate
program and then call that program from the main one.
(Just type the program's name). The subroutine *must* end with
Return or it can just "run off the end"; i.e. if your last statement
executed is the actual last line of the program you don't need
Return.


What I'll sometimes do in my programs is use a variable to indicate
where a subroutine should return:


LBL A
"First thing that calls subroutine"
1->R
GOTO SUB
LBL AR
......


LBL B
"Another thing that calls it"
2->R
GOTO SUB
LBL BR
.....
LBL SUB
"Subroutine"
.....
IF R==1
GOTO AR
IF R==2
GOTO BR
.....


This is really kludgy, but it keeps the program unified.
Sometimes you can figure out other tricks, like if a variable
that you use normally has certain values at certain points, then
you can figure out where to return by the value of that variable.
This means you wouldn't need a separate variable for return
point.


Hope this helps.


--Jon
jnieho38@calvin.edu     www.calvin.edu/~jnieho38


References: