Forum Discussion
EnTerr
12 years agoRoku Guru
"TheEndless" wrote:"renojim" wrote:"TheEndless" wrote:
No "continue" that I'm aware of.
^ Would be really nice to have!
While we're at it, a "switch" (or "select" to stick with the VBScript-like nomenclature) statement would be awesome to have as well!
Continue is easy to emulate with Goto:
for i = 1 to 1000though why won't you just
...
if condition then goto continue
...
continue:
end for
for i = 1 to 1000With GOTO one can pop out of multiple loops - something that ordinary break/continue won't do.
...
if not condition:
...
end if
end for
Emulating switch/select is more complicated but there are options: obviously easiest is IF ... ELSEIF ... ELSEIF... ELSE... ENDIF. If speed is concern, can use AA of functions with expression as selector - this is hairy because of variable scope (has to pass as arguments). Also, can do binary-search-tree of IFs - it's a contrived example but for big N will need only log2(N) comparisons:
if i < 4:
if i < 2:
if i < 1:
... '0
else:
... '1
endif
else:
if i < 3:
... '2
else:
... '3
endif
endif
else:
if i < 6:
if i < 5:
... '4
else:
... '5
endif
else:
if i < 7:
... '6
else:
... '7+
endif
endif
endif