mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Clarify the FOR loop documentation (#1031)
Clarify the FOR loop documentation Fixes #1003 Co-authored-by: Eldred Habert <eldredhabert0@gmail.com>
This commit is contained in:
20
man/rgbasm.5
20
man/rgbasm.5
@@ -1804,11 +1804,29 @@ The
|
|||||||
value will be updated by
|
value will be updated by
|
||||||
.Ar step
|
.Ar step
|
||||||
until it reaches or exceeds
|
until it reaches or exceeds
|
||||||
.Ar stop .
|
.Ar stop ,
|
||||||
|
i.e. it covers the half-open range from
|
||||||
|
.Ar start
|
||||||
|
(inclusive) to
|
||||||
|
.Ar stop
|
||||||
|
(exclusive).
|
||||||
|
The variable
|
||||||
|
.Ar V
|
||||||
|
will be assigned this value at the beginning of each new iteration; any changes made to it within the
|
||||||
|
.Ic FOR
|
||||||
|
loop's body will be overwritten.
|
||||||
|
So the symbol
|
||||||
|
.Ar V
|
||||||
|
need not be already defined before any iterations of the
|
||||||
|
.Ic FOR
|
||||||
|
loop, but it must be a variable
|
||||||
|
.Pq Sx Variables
|
||||||
|
if so.
|
||||||
For example:
|
For example:
|
||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
FOR V, 4, 25, 5
|
FOR V, 4, 25, 5
|
||||||
PRINT "{d:V} "
|
PRINT "{d:V} "
|
||||||
|
DEF V *= 2
|
||||||
ENDR
|
ENDR
|
||||||
PRINTLN "done {d:V}"
|
PRINTLN "done {d:V}"
|
||||||
.Ed
|
.Ed
|
||||||
|
|||||||
Reference in New Issue
Block a user