13. cont: Flagging last record of input

If output from an action block is to be in the form of a list: some elements separated by comma, then the RXS variable cont may be used.

cont

Contains the value ',' each time the action block is executed, except the last time, where cont is assigned the value ' '.

 

Other programming tasks than the production of lists may also benefit from the flag cont signalling 'now last triggering' of the action block.

RXS contains no similar flag for first record. Needing to flag this, some start_switch may be initialized in the general orders. General orders are executed once, just before the first executing of the action block.

Example 13.1:

)action out='myqueue'

9

12

121

2

)endaction

)action in='myqueue'

)& start=1

if start = 1 then do

"Here is the resulting list:"

"("

start = 0

end

word.1||cont

if cont = "" then do

")"

"That's all"

end

)endaction

Output is:

Here is the resulting list:

(

9,

12,

121,

2

)

That's all

|| is the concatenating operator in RXS, meaning consecutive writing of the strings before and after the operator.

Another way of concatenating strings in RXS is to write an empty string between the two strings. That is (referring to the example above):

word.1""cont

In the line above, "" is the empty string.

This last solution may create a conflict with RXS' notation for hexadecimal strings: "12AB"x means the hexadecimal string 12AB.