%exit keyword (SDL script)
The %exit keyword is an optional keyword that can be used in a For or While loop. The %exit keyword provides a way of exiting a loop before all iterations are processed. The %exit keyword is typically used with the evaluation of a condition.
For more information about For loops, see For loop (SDL script). For more information about While loops, see While loop (SDL script).
Syntax
For loop (for collection of items):
%for "<link type>" [%separator "<separator characters>"]
<set of statements>
[%exit]
%endfor
While loop:
%while <condition>
<set of statements for when condition is satisfied>
[%exit]
%endwhile
The following For loop example works in the context of a Class and uses the 'Attribute' automation interface association to evaluate if any of the Attributes owned by the Class have On Instance storage. If any Attributes have On Instance storage, the text '-- On instance attributes' is generated, and the For loop is exited because of the %exit keyword.
%for "Attribute"
%if %custom "Storage" == "on instance" %then
\t\t\t
"-- On instance attributes"
\n
%exit
%endif
%endfor