Page 1 of 1

### Customized Loop Iterators

Posted: Fri Feb 18, 2011 11:32 pm
I was thinking the other day about how nifty it would be if you could use a custom iterator for For loops, that way you could have loops that iterate backwards or increase 2 at a time, etc. And if you want to keep for loops simple, maybe this could be split off into a separate event.

Either way, I think it would be nifty.

### Re: Customized Loop Iterators

Posted: Sat Feb 19, 2011 12:05 am
secondededed

A check box for ascending/ descending, or even a flag on a for loop would be awesome.

### Re: Customized Loop Iterators

Posted: Sat Feb 19, 2011 1:00 am
One way it could work, is 4 parameters
Iterator name, initial value,
Comparison combo box(greater than, less than, equal, not equal to, etc),
And final value

Then the iterator would be declared and behave as any local variable, to be manipulated through actions, and compared before each iteration

### Re: Customized Loop Iterators

Posted: Sat Feb 19, 2011 2:24 am
Don't forget step.

### Re: Customized Loop Iterators

Posted: Sat Feb 19, 2011 4:16 am
For now, we can do something like this:

+ System: For "loop" from initial to final
+ System: final Greater than 0
+ System: (LoopIndex) % step = 0
-> System: do actions

I did an example to illustrate my thoughts. This is the link: http://dl.dropbox.com/u/7967934/Iterati ... ve_0.x.cap

Hope it helps someone.

### Re: Customized Loop Iterators

Posted: Sat Feb 19, 2011 2:05 pm
This should all be doable with an extra 'step' parameter, right?

For 1 to 10 step 2, or for 100 to 10 step -5, and so on.

### Re: Customized Loop Iterators

Posted: Sat Feb 19, 2011 3:23 pm
Yes, but what about for x = -100 to 0 step 5?
Could we do that too?

### Re: Customized Loop Iterators

Posted: Sat Feb 19, 2011 4:10 pm
...yep... you'd just put -100 as the start, 0 as the end, 5 as the step...

### Re: Customized Loop Iterators

Posted: Sat Feb 19, 2011 5:25 pm
Yeah, should be good. Only thing you couldn't do is change the stepping method mid loop, or change the iterator upon a certain condition. Would it be possible to make loopindexes actual local variables ashley?