9. in='xx' Input for action blocks

in

An action block may read an input dataset. General order in is to be assigned the name of such a dataset.

In very general, the action scheme in RXS is the following: Each record or unit (message, row, element...) in input will trigger the action block once. As default, input is seen as a collection of records. That is, if an input dataset contains four records, the action block will be executed four times.

As default, data from actual input record can be accesses inside the action block by the following variables:

unit.1

The variable (which is a stem with one element) unit.1 is assigned the value of the actual input record

word.x

The 'words' of the actual input record is put into variables (stem) word.1, word.2, word.3,... depending on the number of words in the actual record. By 'word' is meant a string of non-blank characters. Say actual records contain three words, then word.4, word.5 etc. will be assigned with strings of length zero.

(A 'stem' in RXS is - as mentioned in section 2 - an array or a one-dimensional table).

Example 8.1:

)action in='myuser.myinput';out='myuser.myout'

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

)endaction

If the first 'word' of each record in the dataset 'myuser.myinput' is numeric, RXS creates a stream of linies in output clarifying how these input numerics are squared. If any record exists in input having a non numeric first 'word', RXS terminates with an error message and nothing is written.


Reading datasets is the default form of input to action blocks. In section 19 is discussed how to access other kinds of input like DB2, MQSeries etc.

in may also denote an internal queue. This core feature of RXS is discussed in section 11.

 

readlim

If only a part of the file is to be read, then specify readlim

Example 8.2:

)action in='myuser.myinput';readlim=10

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

)endaction

This works like example 8.1, but only the first 10 records of 'myuser.myinput' is read. Output is written to stdout (see section 4)