1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-26 17:55:52 +00:00
QB64-PE/internal/help/ON...GOTO.txt
SMcNeill 6e01fc8dce Altered string compare routines (<,<=,>,>=) so they don't give false results with CHR$(0).
Added new _STRCMP and _STRICMP commands for quick string comparisons.
Cleaned up QB64 to finish removing the QUI (quick user insert) code and folders.
Altered UCASE and LCASE routines to be faster in some situations for us.
2014-09-22 08:19:03 -04:00

44 lines
1.3 KiB
Plaintext

ON...GOTO is a control-flow statement that branches to a line number or label in a list depending on a numerical expression's value.
{{PageSyntax}}
:: '''ON''' numerical-expression '''GOTO''' lineornumber[,lineornumber][,...]
* The numerical-expression represents the line or label that it should branch to, 1 branches to the first line or label, 2 branches to the second, etc.
*In QB 4.5 the list can contain a maximum of 60 lines or labels, while there is no limit in QB64.
* The procedure must be used after the number value is determined or in a loop to monitor current user events.
''Example:'' Changing the program flow when a value is not 0.
{{CodeStart}} '' ''
{{Cl|CLS}}
a = 2
{{Cl|ON GOTO|ON a GOTO}} hello, hereweare, 143
{{Cl|END}}
hello:
{{Cl|PRINT}} &quot;you don't get to see this!&quot;
{{Cl|END}}
hereweare:
PRINT &quot;And here we are...&quot;
END
143
PRINT &quot;you don't get to see this neither...&quot;
END '' ''
{{CodeEnd}}
{{OutputStart}}
And here we are...
{{OutputEnd}}
''Explanation:'' Since a equals 2 it goes to the second item in the list (hereweare) and branches to there. Try changing 'a' to 1 or 3!
&lt;center&gt;''Note:'' [[SELECT CASE]] provides a much more convenient way of doing this task.&lt;/center&gt;
''See also:''
* [[ON...GOSUB]]
* [[GOTO]]
* [[GOSUB]]
* [[SELECT CASE]]
{{PageNavigation}}