Integrations (PTC products, 3rd party products and code) > Code integration (Ada, ARINC 653, C, C#, C++, IDL, Java, SQL and VB) > Transformation Development Kit (TDK) > Customizing an ACS Code Generator DLL > Working with SDL script > Working with conditions in SDL script (TDK)
  
Working with conditions in SDL script (TDK)
You can perform conditional execution of statements in the SDL Script through if...then...else statements and while loops. These statements can evaluate the values of properties, variables, item lists or system variables, and then generate code accordingly. For example, you can introduce a Build tag definition for Attributes in the model, and then generate code only for those Attributes that have their Build tag definition set to True.
* 
There are SDL Script extensions that can be used with TDK. For information about, see Overview of SDL script extensions for TDK (SDL script).
If...then...else statements
An if...then...else statement uses the following keywords:
%if — starts the if...then...else statement and specifies the condition to be evaluated. For information about working with variables, item properties, item lists and operators.
%then — specifies a set of statements to run if the condition is satisfied.
%else — optional keyword that specifies a set of statements to run if the condition is not satisfied.
%endif — ends the if...then...else statement.
If...then...else statements can be nested.
Syntax
%if <condition> %then
<set of statements for when condition is satisfied>
[%else
<set of statements for when condition is not satisfied>]
%endif
* 
In this example the value of the Return Type property is evaluated. If the value of the Return Type property is void, 'return;' is generated, if the value is not void, 'return ReturnValue;' is generated.
%if %custom "Return Type" == "void" %then
"return;"
%else
"return ReturnValue;"
%endif
While loops
A While loop uses the following keywords:
%while — starts the While loop and specifies the condition to be evaluated. While the condition is true, the set of statements specified by the While loop are processed. For information about working with variables, item properties, item lists and operators.
%exit — optional keyword for exiting the While loop without processing any remaining statements. The %exit keyword is typically used with the evaluation of a condition.
%endwhile — ends the While loop.
While loops can be nested.
Syntax
%while <condition>
<set of statements for when condition is satisfied>
[%exit]
%endwhile