Re: TI85 Programs - anything like GOSUB?


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

Re: TI85 Programs - anything like GOSUB?



In article <325C53BE.3A5C@voicenet.com>, Webster <webster@voicenet.com>
writes
>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?  Gosub is like
>the old quickbasic statement to goto and execute a group of commands
>then return to the main program.
> - webster


You can fake it by calling the program recursively, something like this:


PRGM Aaaaargh
-------------


s\->\v          /* s = subroutine flag ; copy it to v
0\->\s          /* Reset flag for jump to Lbl MN at keyboard call


If v==0:Goto MN         /*Jump table using v as flag
If v==1:Goto S1
If v==2:Goto S2
If v==3:Goto S3


Lbl MN          /*Main driver
(code ......)


2\->\s:Aaaaargh /*Subroutine call
(code ......)


Stop


Lbl S1          /*Subroutine S1
(code ......)
Return


Lbl S2          /*Subroutine S2
(code ......)
Return


        This works fine. I've never had trouble with it, but I guess if
you were sloppy about program structure, you might eventually fill up
the stack with unRETURNed subroutine calls and crash the program.
        A bonus is that the subroutines are also available at calls from
separate programs, which may be useful if your assembling a suite of
programs.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Stuart Dawson                          Dawson Engineering
49 Knockbracken Park, Belfast  BT6 0HL,  Northern Ireland
sd@dawson-eng.demon.co.uk                 +44 1232 640669
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<


Turnpike evaluation. For Turnpike information, mailto:info@turnpike.com


References: