Loops and conditions

The program flow within a config file can be controlled by the classes loop and condition. The easiest way to access these classes is with the programs LoopPrograms and IfPrograms.

The programs defined in IfPrograms are only executed if the defined condition is met. A typical example is to check whether a file that should have been created in previous programs actually exists. Further options are string comparisons and checking the result of a numerical expression or the return value of an external command.

With LoopPrograms it is possible to repeat the programs defined inside within a loop. The class loop creates a sequence to loop over and defines variables that contain the index and element for the current iteration.

The loop and condition can also be attributed to single config elements (including programs). Config elements with an assigned loop are repeated, with the loop variables being evaluated for each element. If a condition is attributed to a config element in addition to a loop, each element within the loop is only created if the condition is met. Conditions can also be attributed to optional elements without an associated loop. If the condition is not met, the optional element will be treated as if it was not provided.

Example: A program needs all files in a download directory as input. All the inputfiles can be selected manually of course, but it is much easier to assign a loop variable with inputfile={loopFile} and attribute a loop:directoryListing. The loop lists the content of the download directory and assigns each file name to the variableLoopFile=loopFile.