1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-06-29 11:40:38 +00:00
QB64-PE/internal/help/GOTO.txt
SteveMcNeill 33adc04fc4 Add temp folder to repo. It's necessary as well!
Just more initial setting on... nothing much to see here.
2022-04-28 13:39:56 -04:00

50 lines
1.4 KiB
Plaintext

The [[GOTO]] statement sends the procedure to a line label or a line number in the program.
{{PageSyntax}}
: [[GOTO]] {''lineNumber''|''lineLabel''}
'''''IF''' Syntax:''
: IF condition [[GOTO]] {''lineNumber''|''lineLabel''}
{{PageDescription}}
* ''lineNumber'' or ''lineLabel'' must already exist or an IDE status error will be displayed until it is created.
* Can be used in [[SUB]] or [[FUNCTION]] procedures using their own line labels or numbers.
* The frequent use of GOTO statements can become confusing when trying to follow the code and it could also cause endless loops.
* [[GOTO]] is an easy trap for new programmers. Use loops instead when possible.
{{PageExamples}}
''Example:''
{{CodeStart}} '' ''
1 {{Cl|PRINT}} "first line": {{Cl|GOTO}} gohere
2 {{Cl|PRINT}} "second line": {{Cl|GOTO}} 3
gohere:
{{Cl|PRINT}} "third line"
{{Cl|GOTO}} 2
3 {{Cl|END}} '' ''
{{CodeEnd}}
{{OutputStart}}
first line
third line
second line
{{OutputEnd}}
:''Explanation:'' After it prints "first line" it goes to the line label "gohere" where it prints "third line", then it goes to the line that is numbered "2" and prints "second line" and goes to line number 3 and an [[END]] statement which ends the program.
{{PageSeeAlso}}
* [[GOSUB]], [[ON ERROR]]
* [[ON...GOTO]], [[ON...GOSUB]]
* [[DO...LOOP]], [[FOR...NEXT]]
* [[IF...THEN]], [[SELECT CASE]]
* [[Line number|Line numbers and labels]]
{{PageNavigation}}
<