mirror of
https://github.com/KarolS/millfork.git
synced 2026-04-24 12:16:29 +00:00
for loops over arrays
This commit is contained in:
@@ -371,12 +371,18 @@ for <variable> , <start> , <direction> , <end> {
|
||||
}
|
||||
for <variable> : <enum type> {
|
||||
}
|
||||
for <variable> : <array> {
|
||||
}
|
||||
for <variable> , <variable2> : <array> {
|
||||
}
|
||||
for <variable> : [ <comma separated expressions> ] {
|
||||
}
|
||||
```
|
||||
|
||||
* `<variable>` – an already defined numeric variable
|
||||
|
||||
* `<variable2>` – an already defined numeric variable
|
||||
|
||||
* `<direction>` – the type of range to traverse:
|
||||
|
||||
* `to` – from `<start>` inclusive to `<end>` inclusive, in ascending order
|
||||
@@ -411,6 +417,9 @@ for <variable> : [ <comma separated expressions> ] {
|
||||
|
||||
* `<enum type>` – traverse enum constants of given type, in arbitrary order
|
||||
|
||||
* `<array>` – traverse array contents, in arbitrary order,
|
||||
assigning the index to `<variable>` and either the element or the pointer to the element to `<variable2>`
|
||||
|
||||
* `<comma separated expressions>` – traverse every value in the list, in the given order.
|
||||
Values do not have to be constant.
|
||||
If a value is not a constant and its value changes while executing the loop, the behaviour is undefined.
|
||||
|
||||
Reference in New Issue
Block a user