base.Channel.read

Reads a list of data delimited by a separator from the channel.

Syntax

read(
   [ variable primitive-type [,...] ] )
  RETURNS INTEGER
  1. variable is a program variable.
  2. primitive-type is a primitive data type such as INTEGER, VARCHAR(50), etc.
  3. A comma-separated list of simple variables can be provided. These are provided as a variable parameter list.
  4. The variable(s) must be specified between [ ] square brakets.
  5. The record.* notation can be used, to read all values into the members of the record.

Usage

After opening the channel object, use the read() method to read a record of data from the channel.

The read() method uses the field delimiter defined by setDelimiter().

The read() method takes a modifiable list of variables as parameter, by using the [ ] square brace notation.

A call to read() is blocking until the read operation is complete.

If the read() method returns less data than expected, then the remaining variables will be initialized to NULL. If the read() method returns more data than expected, the data is silently ignored.

Any target variable must have a primitive type, or be a RECORD that contains only members defined with a primitive type.

If data is read, the read() method returns TRUE. Otherwise, it returns FALSE, indicating the end of the file or stream.

Note: Files encoded in UTF-8 can start with the UTF-8 Byte Order Mark (BOM), a sequence of 0xEF 0xBB 0xBF bytes, also known as UNICODE U+FEFF. When reading files, Genero BDL will ignore the UTF-8 BOM, if it is present at the beginning of the file. This applies to instructions such as LOAD, as well as I/O APIs such as base.Channel.read() and readLine().

Example

WHILE ch.read([cust_rec.*])
  ...
END WHILE

For a complete example, see Example 1: Using record-formatted data file.