1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-01 15:00:38 +00:00
QB64-PE/internal/help/GOTO.txt

50 lines
1.4 KiB
Plaintext
Raw Normal View History

2017-10-10 14:55:21 +00:00
The [[GOTO]] statement sends the procedure to a line label or a line number in the program.
{{PageSyntax}}
2017-10-10 14:55:21 +00:00
: [[GOTO]] {''lineNumber''|''lineLabel''}
2016-03-18 11:36:04 +00:00
'''''IF''' Syntax:''
2017-10-10 14:55:21 +00:00
: IF condition [[GOTO]] {''lineNumber''|''lineLabel''}
2017-10-10 14:55:21 +00:00
{{PageDescription}}
2021-01-04 18:45:32 +00:00
* ''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.
2017-10-10 14:55:21 +00:00
* 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.
2017-10-10 14:55:21 +00:00
{{PageExamples}}
''Example:''
{{CodeStart}} '' ''
1 {{Cl|PRINT}} "first line": {{Cl|GOTO}} gohere
2019-04-15 01:15:33 +00:00
2 {{Cl|PRINT}} "second line": {{Cl|GOTO}} 3
gohere:
2019-04-15 01:15:33 +00:00
{{Cl|PRINT}} "third line"
{{Cl|GOTO}} 2
3 {{Cl|END}} '' ''
{{CodeEnd}}
{{OutputStart}}
first line
third line
second line
{{OutputEnd}}
2019-04-15 01:15:33 +00:00
:''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.
2017-10-10 14:55:21 +00:00
{{PageSeeAlso}}
* [[GOSUB]], [[ON ERROR]]
* [[ON...GOTO]], [[ON...GOSUB]]
* [[DO...LOOP]], [[FOR...NEXT]]
2016-03-18 11:36:04 +00:00
* [[IF...THEN]], [[SELECT CASE]]
2017-10-10 14:55:21 +00:00
* [[Line number|Line numbers and labels]]
2019-04-15 01:15:33 +00:00
{{PageNavigation}}
<