Difference between revisions of "Foreach"
note on direct array access
imported>Odessa (clarified and added external links) |
imported>Odessa (note on direct array access) |
||
Line 79: | Line 79: | ||
</pre> | </pre> | ||
You can also use the [[Ar_Range]] command to approximate the traditional 'C' style for loop. The code below | You can also use the [[Ar_Range]] command to approximate the traditional 'C' style for loop. The code below prints the numbers 0-10: | ||
<pre> | <pre> | ||
foreach | foreach Entry <- (Ar_Range 0, 10) | ||
Print $ | Print $Entry["value"] | ||
loop | loop | ||
</pre> | </pre> | ||
Note that above we reference <b>Entry["value"]</b> in the [[Print]] function directly, rather than use an intermediary variable (<b>let SomeVar := Entry["value"]..</b>). This is only possible when using NVSE aware functions or the [[Script Compiler Override]]. | |||
==See Also== | ==See Also== | ||
*[[While]] | *[[While]] |