On Gosub and On Goto branch to one of several specified labels, depending on the value of an integer variable.
A value of 0 will cause a branch to the first label, a value of 1 to the second and so on. While On Gosub will continue the execution from the current position as soon as it hits Return in the code section it jumped to, On Goto will not return. See Gosub and Goto for more details on this behaviour.
Mini Tutorial:
; Repeat this loop 10 times For i = 1 To 10 ; get a random number between 0 and 2 j = Rnd(2) ; if j = 0 branch to Label1, if j = 1 to Label2 etc on j Gosub Label1, Label2, Label3 Next ; Display the Screen and wait for the user to press a key Sync WaitKey End ; The labels On Gosub will jump to Label1: Print "I am label 1" Return Label2: Print "I am label 2" Return Label3: Print "I am label 3" Return |
|