#Keyscript error msg
05-Sep-95 09:05:35
Sb: #189050-#Keyscript error msg
Fm: Martin Doudoroff/KUB 74664,2144
To: mike f. wall 71644,177
>> The error message I get is "Too Many FOR/ NEXT Loops" but I really don't
have that many (only 6 in the whole script, and the maximum nesting is 3
deep). I suspect that there is some other cause for this error, but I can't
seem to isolate it. I –AM– using GOTO statements to jump out of some loops.
There is one place where I re-start an outer loop many times, but this seems
like the same thing as an inner loop that gets re-started on every pass, so I
doubt that it should cause any strange behavior. <<
Without seeing your code, I can only speculate about the problem, but you need
to understand that the script language stack only supports forty concurrent
for/next loops. Chances are, your use of GOTO is the problem: if you GOTO out
of a for/next loop, the loop is not cleared, and remains active. If you have
loops nested three deep, it would not take very long to blow the forty-maximum.
It is important to allow a loop to complete execution; the most appropriate
application of the GOTO statement in this context is to bypass code in a loop
(to run out the loop) as in the following pseudo code example:
for [loop]
if [condition] then GOTO SKIP
[operation]
@SKIP
next [loop]
In general, there are very few appropriate instances for using the GOTO
statement — usually GOSUB is preferable. The above instance is an legitimate
exception.
Hope this helps.
Martin