QMBasic - Labels

QMBasic  -  Labels

Top  Previous  Next

 

Any statement of a QMBasic program may be labelled. A label may take one of three formats; a name of the same format as a variable name followed by a colon, a sequence of digits and periods followed by a colon, or a sequence of digits and periods with no trailing colon.

 

The following are all valid label names.

 

REDISPLAY:

100

12.9.6:

 

The label must appear as the first item on the source line. Labels and variables may have the same name though this may lead to some confusion when maintaining a program.

 

Statements that reference the label (e.g. GOSUB) may optionally include the colon after the label name. This is not recommended as it can make using an editor to search for a label in a program more difficult as the search will also find references to the label.

 

Numeric labels are provided for compatibility with other products. Use of numeric labels is discouraged as the "names" do not impart any information about the role of the label. For example, a statement such as

GOSUB 9600

gives the reader no clue about the action performed by the subroutine at label 9600 whereas

GOSUB GET.CUSTOMER.ID

suggests what the subroutine does.