Server Administration > Automate Tasks and Calculate Data Using Event Triggers > What Is an Event Trigger? > Control Structures
  
Control Structures
To execute code based on conditions, use the if…else statement, for example:
if (condition) {
// Code to be executed if condition is true
} else {
// Code to be executed if condition is not true
}
To execute code a specified number of times, use the for loop, for example:
for (var=startvalue;var<=endvalue;var=var+increment) { // Code to be executed}
Note the following:
Sometimes only an if statement is necessary.
You can also add an else if to the if…else statement to make an if…else…else if statement.
Be careful using a for loop. If you notice that the trigger script is taking too long or slowing down the server considerably, check to make sure any for loops are not repeating continuously.