Yes, 'break' and 'continue' in reference to looping control structures, for example:
The 'break' statement terminates the execution of the nearest enclosing loop or conditional statement in which it appears. Control passes to the statement that follows the terminated statement, if any.
Code: Select all
for i = 1 to 100
if somecondition(i) = 1
break
endif
next
In this example, lets say I want to know what the value that 'i' was when the condition became true, and at that point I also want to terminate the loop. Currently to achieve this you have to do something like this:
Code: Select all
for i = 1 to 100
if somecondition(i) = 1
i_val = i
i = 100
endif
next
The 'continue' statement passes control to the next iteration of the repeat, for, or while statement in which it appears, bypassing any remaining statements in the repeat, for, or while statement body. A typical use of the 'continue' statement is to return to the start of a loop from within a deeply nested loop.
Code: Select all
while i > 0
i - 1
x = f( i )
if x = 1
continue
y + x * x
wend
Also, in other languages (C, PHP, etc.) each 'case' section of a 'select' (called 'switch' in other languages) statement has to include a 'break', otherwise, without a break statement, every statement from the matched case label to the end of the 'select', including the default, is executed.
PHP also extends the 'break' statement by allowing a number to follow the 'break' to indicate how many levels of control structures to break from. This is *very* nice to have.
Matthew