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 scriptA particular Automation Engine object type. 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 userIn the Automation Engine, a user is an instance of a User object, and generally the user is a specific person who works with Automic products. The User object is assigned a user ID and then a set of access rights to various parts of the Automation Engine system and product suite. These access rights come in the form of Automation Engine authorizations and privileges, Decision user roles and EventBase rights and ARA web application object rights. You can manage all these centrally in the ECC user management functions. See also, Unified user management. can select the values "YES" and "NO". If the user selects "YES", the script functionPre-defined run book template in the Automation Engine. One single step only, e.g. Start Windows Service, Copy file,… 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 reportA report provides more detailed information about a task's execution or a component..

 

 


Automic Documentation - Tutorials - Automic Blog - Resources - Training & Services - Automic YouTube Channel - Download Center - Support

Copyright © 2016 Automic Software GmbH