Skipping Loop Iterations
MAXScript provides a continue construct that allows you to jump to the end of a for , do , or while loop body <expr> and resume with the next loop iteration.
Its syntax is:
EXAMPLES:
|
for i=1 to 8 do (if i == 5 do continue; print i) -- prints 1..4, 6..8
|
while not eof f do -- read until reach end of file
(
local line=readline f -- read in a line
if line[1] = = "-" do continue -- if comment, skip to next line
line1=parser1 line -- call function parser1
processobjs line1 -- call function processobjs
)
|
If a continue is executed in a for ... collect loop, the expression result for that loop iteration is not collected in the array
of body values.
EXAMPLE:
|
for i=1 to 8 collect (if i = = 5 do continue; i) -- returns #(1, 2, 3, 4, 6, 7, 8)
|