Congrats, your code is worthy to be on
TheDailyWTF.
When you "gosub" something, you have to use
return. Example:
gosub myLabel
rem after "return" is reached, program continues here
rem ---------------------------------------
rem further down...
myLabel:
rem do stuff
return
Your logic is completely flawed. It's very bad to call a subroutine (a gosub) inside a DO/LOOP, and then have another DO/LOOP inside that subroutine. This means that the
return statement will never be reached.
You seem to be calling more and more subroutines, but never ever call
return. This will eventually crash your program (stack overflow).
Having more than 1 main loop is bad practice as well.
As horrible as that code is, I was able to compile it with no problems.
TheComet