Rotating/Looping/Cycling Through Variable Values
coryco2
Posts: 107
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
-Phil
Otherwise, your way is better.
-Phil
Jonathan