I love how ThinBASIC exposes SelectExpression for Select statement.
It would be great to follow this innovative pattern, and have Iteration available inside Foreach.
Imagine this:
long items(5)
for each item in items
item = 2 ^ Iteration
next
' -- Now array contains 2, 4, 8, 16, 32
We could expand further and add IterationBegins and IterationEnds. Useful in cases like:
long items(5) = 1, 2, 3, 4, 5
string myText
for each item in items
myText += item + iif$(not IterationEnds, ",", "")
next
' Produces: myText = "1,2,3,4,5"
The Iteration* helpers would always reflect the current nesting level, so it would work even for nested cycles.
(this would be handy for classic for too).
Petr
Bookmarks