03-12-2013 11:28 AM
Hello,
I was wondering if there's a way to specify the start index of a for loop in a real time sequence? When I drop down a for loop, it specifies an "i" index that always starts at 0. Trying to assign "i" to a value different from 0 before the start of the for loop gives me an error due to redefinition probably because the for loop tries to reinitialize "i" again. Am I missing a simple way of setting "i" to start from something other than 0, or should I just resort to using a while loop? Thanks.
03-12-2013 12:58 PM
There is no way to set the index to anything other than zero. I would recommend just adding your offset to i and storing that in a new variable that you use.
For instance, create an I64 local variable and name it index, then do the following:
index = i + 500
x = FirstArray[index] + SecondArray[index]
03-12-2013 04:13 PM
Hi Jarrod,
Thanks for the suggestion. It would kind of work, but we'd need some special handling to prevent stepping out of array bounds. Ideally I could go usually from index 0 to 99, but sometimes we want to go from 10 to 99. So I was hoping we could just change the start index, or else we may accidentally go from 10 to 109. But at least there's an indirect way around this. Thanks.
03-12-2013 04:29 PM
You can use the arraysize function in an expression to get the size of the array you're indexing through. You can include that in your for loop Iteration Count expression to make sure you don't index out of bounds.
05-01-2013 10:01 AM
How can I pass the For Loop current iteration count to a VS workspace display?
05-01-2013 08:44 PM