12. )trigger and )notrigger; Reacting on empty input

Example 12.1:

)action out='myqueue'

wcount = random(0,5)

do wcount /* loop is executed 0 to 5 times */




)action in='myqueue'


'Square of' word.1 'is' word.1**2


'Sorry, this time no numbers were produced'


In this example the first action block produces a number of elements in the queue 'myqueue'. The number is between zero and five. If by random the number is zero, the second action cannot be executed - normally resulting in an error message from RXS. "queue 'myqueue' does not exist". Using )trigger and )notrigger catches this situation:

If an action block reads from an empty (that is: non-existing) queue, RXS will terminate in error. But this exception may be catched: executing may continue in another branch of the program. This is accomplished by parting the interior of the action block in two parts via the headings )trigger and )notrigger. The )notrigger part is only executed if input is empty, while the )trigger part is executed for each record in input.

The condition 'is empty' is true if any of these conditions do describe input:

(a)  input is a queue which does not exists

(b)  input is a member (in a dataset) which does not exist

(c)   input is a member (in a dataset) which is empty

(d)  input is a dataset which does not exists

(e)   input is a dataset which is empty

If the )notrigger part of the action block is not programmed, situation (a) and (d) results in termination in error, while situation (b), (c) and (e) results in nothing: no execution of the action block, and no termination in error.

RXS does not distinguish between an empty versus a non-existing queue.