Forum Discussion

Komag's avatar
Komag
Roku Guru
6 years ago

How to skip an iteration in a FOR loop?

FUNCTION testNext()
testA = ["apple", 2, "carrot", "dapple", 5, "fapple", "gourd"]
testInt = 0
FOR EACH fruit IN testA
testInt++
IF TYPE(fruit) = "roString" THEN ? fruit ELSE testA.Next()
? "testNext() did one step, fruit " fruit ", testInt" testInt
END FOR
END FUNCTION

This doesn't do what I want, it increments the counter but doesn't skip the rest of the loop cycle, and then the counter is incremented AGAIN at the bottom, so "carrot" never prints out, etc. I'd like to avoid using GOTO if possible. Any ideas?