Application icon

if - else - endif

The if - else - endif statements provide the ability to selectively execute statements within an action. The else statement is optional and the sequences can be nested.

There are two modes of the if statement: one tests the action test state and the other tests a track variable in the current set of available files.

When test if the action test state is selected, the if statement conditionally executes statements based on the action test state being the same as a specified state of true or false. Either the if statements or optionally the else statements; but never both will be executed.

Example 1:

Example 2:

Example 1 tests if all active files have a genre of Rock. Example 2 tests if any active file has a genre of Rock.

The if statement used in examples 1 and 2 does not allow for the handling of both cases. ie. Files with and without a genre of Rock.

The test if Variable n mode allows you to get around the above restriction.

Example 3:

With the if statement as configured in example 3, a track variable in each available file is tested. The result of the test determines which files are available in the if portion of the construct and which file's are available in the optional else portion of the construct. Note that the first statement in example 3 saves individual true or false results to track variable 0.

The three primary compare statements: Compare Dates, Compare Numeric, Compare Text and others allow the setting of a track variable to preserve per file results of a test.

The test if Variable n mode allows you to test if the specified variable is true, false, not empty or empty. empty is defined as completely empty. ie. a variable which contains a space is not empty.

Example 4:

1: Test if the Variable 1 field is empty (Set test state and Variable 2)
2: if Variable 2 is true
3:     ' Process files which have an empty Variable 1
4: endif
5: 
6: if Variable 1 is empty
7:     ' Process files which have an empty Variable 1
8: endif

Lines 6 through 8 are equivalent to lines 1 through 4.

When using a test if Variable n mode you do not have to preserve the track variable's value. The determination as to which files execute where in the if-else-endif sequence is made when the if is executed. Nested tests can use the same variable or the variable can be repurposed. The following is perfectly valid:

Example 5:

 1: Test if the Part of a Compilation field is true (Set test state and Variable 0)
 2: if Variable 0 is true
 3:     Set the Comments field to "Compilation"
 4:     Test if the Album Artist field is equal to "Various Artists" case insensitive (Set test state and Variable 0)
 5:     if Variable 0 is true
 6:         Append "ยท& Various Artists" to the Comments field
 7:     endif
 8: else
 9:     Set the Comments field to "Not a Compilation"
10: endif

The previous example uses Variable 0 for both per file tests, retaining the orrect state for the else clause.


File availability statements can be used with the test if Variable n mode to modify the set of selected files inside the if or else sections. However, when the optional else portion is started the appropriate file availability as determined by the if criteria is restored. Further, whenever endif is encountered or the construct is exited, the initial set of available files in effect when encountering the if are restored.