Small Basic: Label
This article illustrates about label in Microsoft Small Basic programming language.
What Is A Label
A label is a position for the destination from Goto statements. Classic BASIC language uses a line number instead of a label for Goto. Following icon represents a label as IntelliSense in Small Basic IDE (editor).
Syntax about Label
To define a label, colon is placed after the label name.
Label:
To refer (jump into) the label, keyword Goto and the label name is needed. Colon is not needed at this time.
Goto Label
Label Name
As well as variable name, subroutine name starts with any alphabet or underscore "_" and trails with them or also digits. Not as syntax but as manner, label name usually starts with upper case character.
Where to Write Labels
You can write label anywhere in your program. Following list shows the sample to use label.
For i = 1 To n
If data[i] = target Then
found = "True"
Goto Break
EndIf
EndFor
Break:
But actually if there are lots of labels in a program, that program will become difficult to read.
Sample
- Sand (GBK436) - sample of label (and Goto statement)
See Also
- Small Basic: Control Statements
- Small Basic: How to Remove Goto Statements
- Small Basic Getting Started Guide : Chapter 4: Conditions and Branching
- Small Basic Curriculum: Lesson 1.5: Branching and Subroutines
- Small Basic: Capitalization Conventions
- Wiki: Small Basic Portal