RDSEQ

Contents


Rdseq is used to read data of a text file opened by Openi or Openio.

Syntax

   Rdseq varia_list [ Using class ]

Parameters

Element

Description

Restrictions

liste_varia

List of the variables to be read, separated by the character ','.

None.

variable

Variable expressed in one of the following forms :
variable_name
variable_name '('
lis_exp_dim ')'

None.

lis_exp_dim

List of exp_dim separated by the character ','.

The number ofexp_dim must not exceed the number of dimensions of the variable.

exp_ind

Integrer expression of a dimension of the variable.

Must be included between the start index and the end index of the dimension considered.

class

Abbreviation describing the open file.

None

Examples

   # Read of the passwd file
    Char NAME(20), PASSWORD(20)
    Integer USR_NO, GROUP_NO
    Char COMMENT(50), LOGIN_DIR(50), SHELL(50)
    Openi "/etc/passwd"
    adxifs = ':' : adxirs = chr$(10)
    Repeat
     
Rdseq NAME,PASSWORD,USR_NO,GROUP_NO,COMMENT,LOGIN_DIR,SHELL
   #  ... Continuation of the line processing ...
    Until fstat <> 0
    Openi

   # Read of the first 10 words of the line
    Char MOTS(30)(10)
    adxirs = ' '   :# 1 espace
    adxifs = chr$(10)
   
Rdseq MOTS

   # Read on 3 sequential files of the first 10 words of the line
    Char MOT1(30)(10)
    Char MOT2(30)(10)
    Char MOT3(30)(10)
    adxirs = ' '   :# 1 espace
    adxifs = chr$(10)
   
Openi filpath('TRT','ZINSTRUC1','txt') Using [FIC1]
    Openi filpath('TRT','ZINSTRUC2','txt') Using [FIC2]
    Openi filpath('TRT','ZINSTRUC3','txt') Using [FIC3]
    Rdseq MOT1 Using [FIC1]
    Rdseq MOT2 Using [FIC2]
    Rdseq MOT3 Using [FIC3]
    Openi Using [FIC1]
    Openi Using [FIC2]
    Openi Using [FIC3]

Description and comments

Rdseq reads a group of fields recording by recording. Each field is read like a character string and is transferred to the corresponding variable, after an automatic translation.

The Using clause is used to specify the class of the text file that is being read. It is now possible to process several text files at the same time.

In the case of a single-dimension variable for which no index has been specified, as many fields are read as there are elements in the variable (if possible, as explained below). In the case of a multiple-dimension variable, its name MUST be followed by at least one of its dimensions (which brings us back to the case of a single-dimension variable) or a group of indices (in order to characterize a particular element of the variable).

Rdseq is used jointly with the adxirs Adonix system variable to define the recording separator, the adxifs Adonix system variable to define the field separator and the adxium Adonix system variable to define the coding of the character string:

These three variables can be impacted for each file for the Iomode instruction.

Warning ! Rdseq cannot read a file coded in UCS2.

To be fully read by Rdseq, each field must contain 255 characters at most. In any case, the read is carried out to the end of the recording or file. If a recording of a file contains more fields than the number of variables passed as argument, the remaining fields are ignored, otherwise, the "extra" variables are set to zero.

The empty fields are possible and accepted when the field separator is not the space. If the separator is the space, several spaces are considered as a single separator (which makes it possible to separate words without having to pay attention to the number of spaces between each word).

It is possible to read an image file (or Clob) from a sequential file to the format defined by adxium using the Rdseq instruction.  

Remarks

The fstat Adonix system variable is set to 1 if the read has encountered the end of the file. In that case, the variables that could not be read are reset to 0.

The adxseek(0) or adxseek(class) function (for a file open with a class) indicates the current position (in number of bytes) with respect to the beginning of the file. This variable is equal to -1 if no sequential file has been opened in read mode.

An ASCII file containing accented letters cannot be read in UTF8. The following error would be generated: "undefined value"

Associated errors

Error

Description

ERDIM (55)

Variable with more than 2 dimensions.

ERVARI (6)

Variable does not exist.

ERCLAS (7)

Class does not exist.

Associated keywords

WRSEQ - OPENI - OPENIO - ADXSEEK - SEEK - FSTAT - ADXIFS - ADXIRS - ADXIUM - IOMODE


CONTENTS

Copyright © Sage 1999 - 2007