Labels
- Source: https://www.freebasic.net/wiki/wikka.php?wakka=ProPgLabels
- Last revised: 2025-04-15
Defines a location in a program.
Syntax
symbolname :
or
literalnumberDescription
A label can define a place in a program where Goto or Gosub can jump to.
A label can also mark Data blocks, allowing Restore to change the Read sequence.
A label can be a positive integer line number or a symbolname. In both cases, the label must start at the first column of line. A symbolname label must end with a colon (😃 character.
Examples
start GeSHi
vb
'' Compile with -lang fblite or qb
#lang "fblite"
beginning:
3 Print "Hello World!"
Goto beginningend GeSHi
start GeSHi
vb
'' compile with -lang qb
'$lang: "qb"
'' Labels can be used to "bookmark" DATA blocks, allowing RESTORE to alter the READ sequence.
Read a,b,c
Restore here
Read d,e
Print a,b,c,d,e
Data 1,2,3,4,5
here:
Data 6,7,8end GeSHi
Output:
1,2,3,6,7Dialect Differences
- Line numbers with decimals is available only in the -lang qb dialect.
Differences from QB
- None if compiled in the -lang qb dialect.
See also
GosubGotoRestore
Back to DocToc