In this section: |
This topic illustrates the use of various iWay Functional Language (iFL) statements.
The following examples use the _IF statement to filter messages and capture events.
In the second example, the _IF statement contains an optional third parameter. The third parameter supplies an expression that will be evaluated when the first parameter evaluates to false.
_IF ( _cond(_xpath(//number),>,0), _expose(myevent,_xpath(//number),db,int) )
where:
Is an iFL function that checks a message for the value of the first occurrence of a number element (_xpath(//number)). It returns true if the value of the number element is greater than 0.
Is an iFL function that is executed if the value of the first occurrence of the number element is greater than 0. The _expose() function captures the event named myevent and saves the element value as a fact in the in-memory database (db). The data type of the fact is int.
_IF ( _cond(_xpath(//number),>,0), _expose(gtzeroevent,_xpath(//number),db,int), _expose(notgtzeroevent,_xpath(//number),db,int) )
where:
Is an iFL function that checks a message for the value of the first occurrence of a number element (_xpath(//number)). It returns true if the value of the number element is greater than 0.
Is an iFL function that is executed if the value of the first occurrence of the number element is greater than 0 (that is, the first parameter evaluates to true). This _expose() function captures the event named gtzeroevent and saves the element value as a fact in the in-memory database (db). The data type of the fact is int.
Is an iFL function that is executed if the value of the first occurrence of the number element is not greater than 0 (that is, the first parameter evaluates to false). This _expose() function captures the event named notgtzeroevent and saves the element value as a fact in the in-memory database (db). The data type of the fact is int.
If you supply only one parameter on an _IF statement, you can evaluate a Boolean expression.
and or
_IF(yes and true)
returns true.
_IF(yes or false)
returns true.
_IF(yes or true and 0)
returns false.
_IF(yes and _IF(_IF(true) and _IF(1)))
returns true.
_IF(yes or _IF(true,_IF(true),_IF(no)) and 0)
returns false.
You may not know the events that you need in order to infer a complex event or events. You can dynamically discover events by capturing data in a message and using the data values as part of the event name.
_expose(event._XPATH(//sale/salesrep/name),_XPATH(//sale/price),DB,float)
In the preceding example, the tap captures the name of the sales representative and uses it to construct the name of the event. The following string is the prefix for the event name:
event
For example, this technique dynamically creates an event named
event.bob
where:
You can capture a sales event for every sales representative, without having to first create the event.
iWay Software |