Difference between revisions of "Foreach"

250 bytes added ,  09:22, 28 August 2014
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 [[Print|prints]] the numbers 0-10:
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 entry <- (Ar_Range 0, 10)
foreach Entry <- (Ar_Range 0, 10)
     Print $entry["value"]
     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]]
Anonymous user