IF

Parameters

OrderNameTypeDesc
1conditionanyThe condition to determine if the function should be run
2truefunctionfunctionThe function to execute if the condition is true
3falsefunctionfunctionThe function to execute if the condition is false

Returns

Copies the stack from the call onto the stack.

Description

This command runs the truefunction function if the condition is true.

This command runs the falsefunction function if the condition is false.

The condition is considered true in the following circumstances…

Data TypeTrue If
const'1', 'True', 'Yes','y','t'
list or mapContains more than 0 items

Note that the behaviour of GET and SET is slightly different when in the if. Calling set will only set a value for the nested function - you can't set values that will be accessible to the calling function.

However, GET can access information stored by any function in the calling hierarchy.

Example

To demonstrate the function, let's look at a simple example.

'TE101' ASSET RELS 'Location' RELATIONSHIP CONTAINS [ 'YES' ] [ 'NO' ] IF

This function will return 'Yes' if the asset TE101 is part of the Location hierarchy, or “No” if it isn't.

See Also