15. getqueue: Keyed data from queues

If you put some input record into a RXS queue holding a comma - outside quotes - the thereby established two parts of he record will be saved separately. In reading of the RXS queue, the first part is assigned to variable unit.1 and the second part is assigned to variable unit.2. As mentioned before, unit.1 is further split into variables word.1, word.2, word.3 etc.

unit.2 may also be accessed by the command getqueue:

The RXS function getqueue('queue_name', 'element_value') makes a search through the queue 'queue_name' to find a element where unit.1 holds the value element_value. If the search is successful, the function returns the value of unit.2. Otherwise: if the element is not found, if the found element does not hold a value for unit.2 or if the queue 'queue_name' is not found, getqueue returns an empty string (a string of length zero).

Example 15.1:

)action out='q1'

'Yrsa Nielsen', 'bike mechanic'

'Hugo Jensen', 'account manager'

'Niels Olsen', 'brazier'

)endaction

)action in='q1' /*Example of accessing unit.1 & unit.2 in a queue: */

unit.1 'is' unit.2

)endaction

)action /* Example of accessing unit.2 in a queue via getqueue: */

' '

'What position has Hugo Jensen: '

getqueue('q1', 'Hugo Jensen')

)endaction

Ouput is:

Yrsa Nielsen is bike mechanic

Hugo Jensen is account manager

Niels Olsen is brazier

 

What position has Hugo Jensen:

account manager

The line getqueue('q1', 'Hugo Jensen') in the example, is a function call. The result of the function call is a string. And strings in RXS are written out to stdout.