Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: nesting of structures too complex or deep stack levels error 3353:struct error 5058 Goto statement found in execution control block
Each time you use any of these three structure operators, you use up one more levels in the stack of 100. When WinBatch processes the matching terminator (Endif, Next, or EndWhile, respectively), it frees up that level.
But when you use a Goto to "jump" out of a structure, WinBatch never processes the pending terminator(s) and consequently never frees up those levels.
Technically we claim nested gotos are illegal, but try to save you the first hundred times. Then we give up with the 3353 error.
Get rid of the goto's or the structures. Do not mix gotos with structured programming... And do not use gosub's instead of goto's (Make sure gosubs RETURN).
Draw a line from each goto to its destination. A goto that crosses a structure boundary is really a no-no. For Example, the following code will give you the error:
a=1 b=2 for xx=1 to 3 if a!=b goto zork endif :zork next Message("Too bad","It does not make it this far")The goto crossed a structure boundary (the endif) and caused a problem then it hit the next statement, the poor feeble parser having never seen the endif. Here's more clarification:
;This by definition crosses a data structure if x==1 goto zork endif ;This does not automatically violate and rules if x==1 then goto zork ;But here it does for xx=1 to 10 if xx=5 then goto zork next :zork
RE: THE 100 LEVEL LIMIT:
Note that if you are 5 levels deep and perform a Goto, you have lost 5 levels, which can never be recovered. After you do that 20 times, you get the "Nesting of Structures Too Complex or Deep..." error message.
If you're going to use gotos, then re-structure your code so that you set a flag variable inside a structure, and then conditionally perform the next sections of your code. This would look something like:
Inside of the structure (within a while loop, for example), set the flag=1:
while..... ........ flag=1 endwhileThen, outside of the structure:
if flag==1 then goto labelNow the goto will NOT use up a level of the stack. Here's an example:
msg = MsgTextGet("Trumpet Winsock") If msg == "Connected" getmail=1 Else getmail=0 Endif If getmail == 1 then Goto eudoragetmail If getmail == 0 then Goto waitforconnection
The same stack limitation applies to GOSUB. Until you return back to the point where you did the Gosub, you are still using up a portion of the stack. You can also resolve the problem by pulling out part of the script and calling these secondary scripts with the Call function.
Article ID: W12997
Filename: Nesting of Structures Too Complex or Deep .txt
File Created: 2019:02:20:10:24:30
Last Updated: 2019:02:20:10:24:30