Integrations (PTC products, 3rd party products and code) > Code integration (Ada, ARINC 653, C, C#, C++, IDL, Java, SQL and VB) > SDL script for generating code > Keywords > %exit keyword (SDL script)
  
%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