Hi
It's surprising to me there hasn't been such discussion in the past.
I'm looking for 'foreach' alternative in Powerscript. I mean: In my app I use multirow selection everywhere it's possible. Therefore iterating through for-next loop is one of the most common action I usually do. Wouldn't be nice to have a special command just for making code smaller and safer?
The idea of foreach is taken from Lua language which I see very useful:
string ls_array[]
string ls_var
...
foreach ls_var in ls_array
//do something with ls_var
next
Second idea - taken from C++ - just enhancement of for-next loop:
string ls_array[]
...
long ll_n
for ll_n in ls_array
//do something with ls_array[ll_n]
next
What's your opinion?
No because you're iterating through ls_array. You wand all available indexes from ls_array.
The idea behind is:
You need two access modes:
1. Simple (foreach) which gets you a value of the item and fits to most usual scenarios
2. General (for) which allows you access to an array element.
Both without working with pointers, C++ iterators etc.
Another alternative would be to add lambdas but I see this option too complex for Powerscript.
Never too old to learn :)
Thanks for the explanation.