This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
en:foreach [2020/04/21 19:10] admin created |
en:foreach [2020/04/26 22:32] (current) admin |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== For / Next (Statement) ===== | + | ===== For Each / Next (Statement) ===== |
==== Format ==== | ==== Format ==== | ||
- | **for** [[variables|variable]] | + | **for each** [[variables|variable]] |
+ | (tab)[[programsyntax|statement(s)]]\\ | ||
+ | **next** [[variables|variable]] | ||
+ | |||
+ | **for each** | ||
+ | (tab)[[programsyntax|statement(s)]]\\ | ||
+ | **next** [[variables|variable]] | ||
+ | |||
+ | |||
+ | **for each** [[variables|key]] **%%-> | ||
(tab)[[programsyntax|statement(s)]]\\ | (tab)[[programsyntax|statement(s)]]\\ | ||
**next** [[variables|variable]] | **next** [[variables|variable]] | ||
Line 7: | Line 16: | ||
==== Description ==== | ==== Description ==== | ||
- | The FOR and NEXT commands are used in conjunction | + | The FOREACH |
- | After each NEXT command, variable is incremented by 1 (the default), or by [[numericexpressions|step_expression]] if the optional STEP is used, until the variable is greater than [[numericexpressions|stop_expression]] for positive step values, or less than [[numericexpressions|stop_expression]] for negative step values. | + | |
+ | If the array is two dimensional it will be traversed through | ||
==== Example ==== | ==== Example ==== | ||
< | < | ||
- | for i = 1 to 10 | + | for each i in {1,2,3,4} |
+ | print i | ||
+ | next i | ||
+ | x = {' | ||
+ | for each i in x | ||
print i | print i | ||
next i | next i | ||
- | |||
- | print "after the for " + i | ||
</ | </ | ||
displays | displays | ||
Line 24: | Line 36: | ||
3 | 3 | ||
4 | 4 | ||
- | 5 | + | a |
- | 6 | + | b |
- | 7 | + | c |
- | 8 | + | |
- | 9 | + | |
- | 10 | + | |
- | after the for 11 | + | |
</ | </ | ||
==== See Also ==== | ==== See Also ==== | ||
{{page> | {{page> | ||
+ | |||
+ | ==== History ==== | ||
+ | |2.0.0.0|New To Version| |