Nested Gosubs

Nancy Palmquist nlp at vss3.com
Sun Oct 31 05:39:41 PST 2004


Tim Fischer wrote:

> I'm confused on the nested gosubs limit.
> 
> I have a table that has 4 nested gosubs.  Meaning:
> 
>   1  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        ~ If:
> 
>        Then: gosub one
> 
>   2  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        ~ If:
> 
>        Then: end
> 
>   3  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
> one    ~ If:
> 
>        Then: gosub two
> 
>   4  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        ~ If:
> 
>        Then: return
> 
>   5  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
> two    ~ If:
> 
>        Then: gosub three
> 
>   6  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        ~ If:
> 
>        Then: return
> 
>   7  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
> three  ~ If:
> 
>        Then: gosub four
> 
>   8  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        ~ If:
> 
>        Then: return
> 
>   9  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
> four   ~ If:
> 
>        Then: goto one


It is unusual to hit the limit unless your programming flow is flawed. 
The usual mistake is when you mix up a goto with the gosubs, as I have 
done on your line 9.  This will cycle until it hits the limit.

WHEN processing can cause this to be hit also.  Be careful when you use 
a gosub in a when process that the subroutine does not cause the WHEN to 
end by using a SCREEN (most likely) command.  It will leave your GOSUB 
active and the logic following the SCREEN undone.

Nancy
Nancy



-- 
Nancy Palmquist
Virtual Software Systems
PHONE: (412) 835-9417			Web site:  http://www.vss3.com



More information about the Filepro-list mailing list