Udostępnij za pośrednictwem


Small Basic - Goto Loops

Goto statements were first used for loops; try out the example code below. And we'll also show you the output.

 

Copy and paste this program into Small Basic:

' Uses the Goto keyword to create a loop

x = 1

Start: ' A label named Start marks this line of the progarm

TextWindow.WriteLine(x)

x = x + 1

If (x <= 5) Then

    Goto Start

EndIf 

Output:

1

2

3

4

5

 

You can create loops this way, but most programmers don’t. Small Basic has two statements (For and While) that you’ll use for loops instead. 

 

Small and Basically yours,

   - Majed Marji & Ninja Ed

Comments