Control Structures
The macro syntax does not provide direct support for control structures such as if-then-else branches or loop constructs, but only single-line macro expressions with the elements described at Macro Expressions.
However, some macro functions can be used to emulate the basic functionality of Control Structures, in particular the functions If(), IfElse() and ForEachItem(). Detailed information on the meaning and use of these macro functions can be found at Control Structures.
These functions represent normal functions in terms of syntax and operation, but the following difference should be noted for the If() and IfElse() functions:
Normally, functions are executed recursively from the inside out. First comes the evaluation of all existing subexpressions, whose result values serve as the parameters of the parent functions. Then comes the execution of the parent functions. However, in the case of functions such as If() and IfElse(), not all subfunctions are meant to be executed across the board. Instead, execution must take place only depending on a condition (the reason being that in this condition a prerequisite for its execution can be checked under certain circumstances and otherwise an execution error will occur). Therefore, in the case of such functions, only the subexpression representing the condition is evaluated first. Only then is the subexpression corresponding to the result of this evaluation executed. In the case of If(), depending on the result, no subexpression can be executed at all.