Conditional assignments¶
Conditional assignments offer the option of only assigning a value to a variable if a condition is fulfilled.
In general, the following applies:
- Variable = If
<Condition>
is fulfilled, then the content of<Value>
is assigned to the variable. - If the condition is not fulfilled, the content of the variable remains unchanged.
Syntax¶
Where applies:
- n addresses a specific variable.
- condition is a placeholder for the keyword that describes the condition.
- comparison partner is inserted in the determination of the condition.
- value is the content that is assigned if the condition is fulfilled.
The following conditional assignments are available in the script package:
Assignment | Description |
---|---|
$func::getifcomponenttypeid(<ID> , <Value> ) | Checks whether the script is executed with a reference to the component type ID that is passed via <ID> |
$func::getifcomponentid(<ID> , <Value> ) | Checks whether the script is executed with a reference to the component ID that is passed via <ID> |
$func::getifuserid(<ID> , <Value> ) | Checks whether the script is executed with a reference to the user that is passed via <ID> |
$func::getifip(<IP> , <Value> ) | Checks whether the script is executed on the computer that is passed via <IP> .<IP> can be either the IP address or the host name |
$func::getiffileexists(<File> , <Value> ) | Checks whether the file that is passed via <File> exists |
$func::getifjobid(<Job-ID> , <Value> ) | Checks whether the script is executed with a reference to the job ID that is passed via <ID> . This condition is only available for the BeforeUpload, AfterUpload and AfterSchedulerJobRun events. |
$func::getiftrue(<Condition> , <Value> ) $func::getiffalse(<Condition> , <Value> ) | Interprets the condition described in "chCondition". The return value is the logical result of the condition. Examples of the condition formulation are: a=b a<b a>b a!=b a<=b a>=b |
Special words for a true are: true, yes, y, 1. | |
Special words for false are: false, no, n, 0,<empty> . | |
The following examples perform the assignment:$def::var1 = $func::getiftrue(0<=5, value) $def::var1 = $func::getiftrue(1=1, value) $def::var1 = $func::getiftrue(true, value) . | |
The following examples do not perform an assignment:$def::var1 = $func::getiftrue(6<4, value) $def::var1 = $func::getiftrue( , value) $def::var1 = $func::getiftrue(false , value) | |
$func::getiffalse is the inverted method of $func::getiftrue and works analogously. |