base.Channel.read
Reads a list of data delimited by a separator from the channel.
Syntax
read(
[ variable primitive-type [,...] ] )
RETURNS INTEGER
- variable is a program variable.
- primitive-type is a primitive data
type such as
INTEGER
,VARCHAR(50)
, etc. - A comma-separated list of simple variables can be provided. These are provided as a variable parameter list.
- The variable(s) must be specified between
[ ]
square brakets. - 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.
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.