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.
However, when CodeA is a subroutine, it fails to execute, and CodeB is the first thing run. Here's an example, where x and a are bytes, and subA is a short subroutine.
Quite so. An identifier at the beginning of a line followed by a colon is taken to be a label. You can work around this restriction in one of two ways:
pjc30943 wrote:I guess labels are supported for compatibility with assembly.
No. Their purpose is to be the target of a GOTO instruction. A GOTO is rarely necessary but occasionally it can be used to good effect when the alternative is even less palatable.
Private Sub ValidateValue(ByVal intValue As Integer)
If intValue > 10 Then
Exit Sub
Else
ProcessValue(intValue)
MessageBox.Show("Valid Number Entered")
EndIf
End Sub
On the other hand, the Exit Sub statement and related Exit statements serve exactly the same purpose as a goto/label combination. It's just that the target is implicit instead of being an explicit label.
Woops...I didn't realize ZBasic supported goto, but I should have since it's vb based (and looking at it now, there it is in the docs). Hence the assumption that labels was for use with asm GOTOs. Thanks for the clarifications.