Conditional statements and iterations
In this section, we'll take a look at the conditional and looping statements that are available at compile time.
if...elseif...else
The if statement checks that a preprocessor variable is set to a certain value. If it does, the code between it and the closing endif statement will be compiled. Optionally, it can be followed by an elseif or e
lse statement, allowing you to compile other code if the initial condition is false. The entire block must end with an endif. Here's an example that only compiles a Property
element if the preprocessor variable myVar
is equal to 10.
<?if $(var.myVar) = 10 ?> <Property Id="newProperty" Value="5" /> <?endif?>
Here's a more complex example that utilizes the elseif and else statements:
<?if $(var.myVar) = 10 ?> <Property Id="newProperty" Value="5" /> <?elseif $(var.myVar) > 10?> <Property Id="newProperty" Value="6" /> <?else?> <Property Id="newProperty" Value...