1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-03 01:51:20 +00:00
QB64-PE/internal/help/NEXT.txt

43 lines
1.5 KiB
Plaintext
Raw Normal View History

2017-10-10 14:55:21 +00:00
[[NEXT]] is used in a [[FOR...NEXT|FOR]] counter loop to progress through the loop count.
2017-10-10 14:55:21 +00:00
{{PageSyntax}}
: [[FOR]] {{Parameter|counterVariable}} = {{Parameter|startValue}} [[TO]] {{Parameter|stopValue}} [{{KW|STEP}} {{Parameter|increment}}]
:: ''{code}''
:: ⋮
: [[NEXT]] [{{Parameter|counterVariable}}]
2017-10-10 14:55:21 +00:00
{{PageDescription}}
2019-04-15 01:15:33 +00:00
* [[NEXT]] is required in a FOR loop or a [[ERROR Codes|"FOR without NEXT" error]] will occur.
2017-10-10 14:55:21 +00:00
* The FOR variable name is not required after [[NEXT]].
* [[NEXT]] can be grouped with other NEXTs in nested FOR loops using colons like [[NEXT]]: [[NEXT]]
2019-04-15 01:15:33 +00:00
* [[NEXT]] can also end more than one nested [[FOR...NEXT|FOR]] loop using comma separated variables like [[NEXT]] j, i
2017-10-10 14:55:21 +00:00
* [[NEXT]] increases the FOR loop count, so after the loop is over the counterVariable's value will be stopValue + 1 (or stopValue + increment).
* [[NEXT]] is also used with the [[RESUME]] statement.
2017-10-10 14:55:21 +00:00
{{PageExamples}}
''Example:'' Finding the FOR variable value AFTER a simple counter loop to 10.
{{CodeStart}} '' ''
FOR i = 1 TO 10
PRINT i;
NEXT i
2019-04-15 01:15:33 +00:00
PRINT "AFTER the LOOP, NEXT makes the value of i ="; i '' ''
{{CodeEnd}}
{{OutputStart}}
1 2 3 4 5 6 7 8 9 10 AFTER the LOOP, NEXT makes the value of i = 11
{{OutputEnd}}
2017-10-10 14:55:21 +00:00
''Result:'' The last value of i = 11 although FOR only looped 10 times. '''Only use the count values while inside of the loop or compensate for this behavior in your code.'''
2017-10-10 14:55:21 +00:00
{{PageSeeAlso}}
* [[FOR...NEXT]]
* [[DO...LOOP]]
* [[RESUME|RESUME NEXT]]
2019-04-15 01:15:33 +00:00
{{PageNavigation}}
<