Rotating/Looping/Cycling Through Variable Values
I am looking for the most code-efficient way to allow a variable value to be cycled through a given set of consecutive whole values in a continual loop. For example, given the set {5, 6, 7, 8, 9, 10}, I want the variable to start with a value of 5, advance through each value until it reaches 10; then return to 5 and repeat.
This is one way do that:
Can anyone figure out a more compact way to do this?
This is one way do that:
CyclingValue:=5
REPEAT
CyclingValue++
if CyclingValue==10
CyclingValue:=5
Can anyone figure out a more compact way to do this?

Comments
repeat repeat i from 5 to 10 'do stuff with i-Phil
IF ConditionX CyclingValue++ if CyclingValue==10 CyclingValue:=5repeat repeat i from 5 to 10 repeat until ConditionX 'do stuff with new i valueOtherwise, your way is better.
-Phil
VAR long var_i { 15 bytes } DAT dat_i long 0 { 13 bytes } PRI just_4_test : local_i { 11 bytes } if ++local_i => 10 local_i := 5Incorporating the prefix increment saves one byte. Also, using local variables rather than globals is faster / fewer byte-codes.Jonathan