Discussion about the ZBasic language including the System Library. If you're not sure where to post your message, do it here. However, do not make test posts here; that's the purpose of the Sandbox.
I'm creating a subroutine and there are several points where I want to break out of the routine at certain points if certain conditions are met.
In PBASIC I would simple use a RETURN inside a conditional statement. It doesn't look like ZBasic has anything like "RETURN". . .does that mean I'm going to have to create large nested conditional statement for these subs? That will certainly work, but seems very complicated.
Here's the PBASIC code I'm trying to replicate (there are many more statement like this below, so we're talking "super nesting" I think):
The compiler seems to be complaining quite a lot when I have "End Sub" in multiple locations inside a single Sub. . .a Gosub in PBASIC will jump back whenever it hits the first "Return", it doesn't seem like I can do that here.
My work-around has been to create a Boolean variable called "BREAK" and just have all parts of the sub check to see if that has been set to TRUE before executing, so once that's set, everything else gets skipped. I just though there might be an easier way to do this.
everest wrote:The compiler seems to be complaining quite a lot when I have "End Sub" in multiple locations inside a single Sub.
You can only have one End Sub for a subroutine since it marks the actual end of the subroutine. Perhaps you misunderstood my previous post. I referred to Exit Sub not End Sub.