Script Statement: It verifies whether the value of a variableIt stores or retrieves values dynamically at runtime. An individual Automation Engine object type. complies with certain values and, depending on the result, it runs various statements.
:SWITCH Variable
:CASE Expression1
[Statements]
[:CASE Expression2
[Statements]
...
]
[:OTHER
[Statements]
...
]
:ENDSWITCH
Syntax |
Description / Format |
---|---|
Variable |
The name of the variable whose value should be verified. |
Expression1, Expression2 ... |
Conditions or the values that form the conditions. |
Statements | One or several statements that should be processed when the variable complies with the specified value. Format: scriptA particular Automation Engine object type. statement |
A SWITCH statement forms one or several conditions by running various statements depending on a variable's value. A :SWITCH block consists of one or several :CASE statements and must end with :ENDSWITCH.
With each :CASE statement, you determine a value or an expression that should be evaluated. It is followed by the statements that should be processed when the value or the expression applies. These statements end with a new :CASE line or with :ENDSWITCH.
You can also define an :OTHER branch whose statements will be processed when no :CASE statement applies. Note that the :OTHER statement must only be used after the last :CASE statement.
You can also use several :CASE statements in a row without explicitly separating them. They are connected by OR relations. Note that this is only useful in complex expressions.
You can also use :IF statements to evaluate expressions. Their statement block, however, is limited to one condition and one Else condition.
As values, you can also use complex expressions such as arithmetic terms:
:SWITCH &NUM#
:CASE 3*(5-2)
: PRINT "&NUM# = 9"
:ENDSWITCH
You can also use the construct between value1 and value2, and the operators <, >, <>, <=, >=, = in :CASE lines. In this case, you must specify the string "Y" instead of the variable name:
:SET &STATUS# = GET_STATISTIC_DETAIL(&RUNID#,STATUS)
:SWITCH "Y"
:CASE &STATUS# between 1300 and 1599
:CASE &STATUS# between 1700 and 1799
: PRINT "The taskAn executable object that is running. Tasks are also referred to as activities. &RUNID# is active."
:CASE &STATUS# between 1600 and 1699
: PRINT "The task &RUNID# is in a waiting condition."
:CASE &STATUS# between 1800 and 1899
: PRINT "The task &RUNID# has aborted."
:CASE &STATUS# >= 1900
: PRINT "The task &RUNID# has successfully ended."
:ENDSWITCH
The following example retrieves the current day of the week as a number and verifies it using a SWITCH statement. Mondays and Fridays, a specific jobAn Automation Engine object type for a process that runs on a target system. starts.
:SET &DATE# = SYS_DATE_PHYSICAL("DD.MM.YYYY")
:SET &WEEKDAY# = WEEKDAY_NR("DD.MM.YYYY:&DATE#")
:SWITCH &WEEKDAY#
:CASE 1
: SET &ACT# = ACTIVATE_UC_OBJECT(JOBS.MONDAY, WAIT)
:CASE 5
: SET &ACT# = ACTIVATE_UC_OBJECT(JOBS.FRIDAY, WAIT)
:OTHER
: PRINT "No Processing."
:ENDSWITCH
See also:
Script Element | Description |
---|---|
They analyze an expression and depending on the result, they run statements. |
Script Elements - Data Sequences
About Script
Script Elements - Alphabetical Listing
Script Elements - Ordered by Function
Automic Documentation - Tutorials - Automic Blog - Resources - Training & Services - Automic YouTube Channel - Download Center - Support |
Copyright © 2016 Automic Software GmbH |