Before writing a full-fledged game, I want to introduce you to the concept of Goto. Goto is a very simple command, but it can be misused very easily, so I recommend using Goto as sparingly as possible. Almost always, if something can be done by using Goto, it can be done in another way.
Goto works like this: you add a label somewhere in your code, and Goto jumps to that label. (See Figure 2.12.) The best illustration of this is a sample program.
;demo02-10.bb Demonstrates use of Goto .label Print "Hello" selection = Input("Enter 1 if you want me to repeat 'Hello' = => ") If (selection = 1) Goto label EndIf End
The output is shown in Figure 2.13.
Note
Notice that I did not include WaitKey in this program. Because the program repeats and then ends with an End command, the WaitKey is not necessary.
As you can see in Figure 2.12, calling Goto starts the program back at the top. This is accomplished by putting .label at the top of the program. You can make Goto move anywhere by simply moving the line .label. Notice that when you define the label, you put a period (.) before it. When you call it from Goto, however, you discard the period.
3.144.172.220