Automation Engine Script Guide > Introduction > First Steps > IF Conditions

IF Conditions

Objectives:
- Creating IF conditions
- Adding an ELSE block

Lesson 7

In AE Script, you can also define that statements are only processed if particular conditions have been met. Conditions are created by using the script element :IF... :ELSE... :ENDIF.

The following example creates a condition that compares two numbers. Specify the script element :IF with a condition. Enter all scripting lines that should be processed when the condition is met. Each IF block ends with :ENDIF.

:IF 1<2
: PRINT "Condition is met"
:ENDIF

The next example combines a READ mask (see previous lesson) with an IF statement. Create a mask in which a user can select the values "YES" and "NO". If the user selects "YES", the script function will retrieve the current date and time and output them in the activation protocol.

:READ &VAR#,"'YES','NO'", "Retrieve current date and time?","YES"

:IF &VAR# = "YES"
: SET &TIME# = SYS_TIMESTAMP_PHYSICAL()
: PRINT &TIME#
:ELSE
: PRINT "No retrieval of date and time."
:ENDIF

You can use :ELSE within an IF block in order to determine the statement that should be processed if the condition is not met. In this case, a message is written to the activation report.