What exactly are you trying to do? Why are you increment in the for each loop?
FUNCTION testNext()
testA = ["apple", 2, "carrot", "dapple", 5, "fapple", "gourd"]
for fruit = 0 to testA.count()-1
if type(testA[fruit]) = "roString" ? testA[fruit]
? "testNext(): did one step; fruit="+testA[fruit].toStr()+" index="+fruit.toStr()
next fruit
END Function
Wouldn't that be easier.. I mean sorta? Are you just trying to build a string of names of fruit from among a non sorted one dimensional array? What exactly are you trying to do sir.. lol
Is shorter better or does adding that extra reference to the array mean it slows down the code and longer is better. You be the judge. you need a huge array to test the millisecond differences. In a list small as this the difference is NIL.
----------------------------------------------------------------
For some reason the Roku docs do not note the special use of "next varname" as an option.
Take this for example:
for fruit = 0 to testA.count()-1
for potion = 0 to testB.count()-1
for skill = 0 to testC.count()-1
Now at any time we can "Next fruit" or "Next potion" or "Next skill" and not involve the other nested for loops incrementing. Using "End for" will interact with the last nested for. Using "next varname" will increment the loop for the associated varname.
Why isn't this in the Roku documentation?
@RokuTannerD This is an oversight and should be corrected. You can use "Next varname" when using "For varname=" in a loop. When doing this it allows incrementing nested for's out of order which the "End for" does not allow. Thanks. ^_~
https://developer.roku.com/docs/references/brightscript/language/program-statements.mdit is that page that is incorrect --^
Also.. why can't we
For each {varname1 varname2 varname3} in var ? Other languages allow this but not brightscript.