Does a counter value get processed?

# Thread: Does a counter value get processed?

1. ## Does a counter value get processed?

Hi All Again!
So my next question is when you have a loop and you have a statement such as C = 0 to 6 the ICD will show the value of C and I noticed that C will have a value of 7, one higher than the limit of 6. Does your code actually process this value of 7 until it gets to the next C = 0 to 6? Seems like you would need a statement If C =< 7 go to .....?

Thanks, Ed

2. ## Re: Does a counter value get processed?

I suppose you're talking about a FOR-NEXT loop. From the manual:
Code:
`FOR Count = Start TO End {STEP {-} Inc}{Body}NEXT {Count}`
1) The value of Start is assigned to the index variable, Count. Count can be a variable of any type.
2) The Body is executed. The Body is optional and can be omitted (perhaps for a delay loop).
3) The value of Inc is added to (or subtracted from if "-" is specified) Count. If no STEP clause is defined, Count is incremented by one.
4) If Count has not passed End or overflowed the variable type, execution returns to Step 2.

So your code FOR C = 0 to 6 will execute the body of the loop 7 times and then stop. C will be incremented to 7 but the body of the loop will not execute since 7 is larger than 6. That's where it stops.

/Henrik.