GETSEQ |
Getseq is used to read data from a binary file opened by Openi or Openio.
Getseq exp_ent, liste_varia [ Using classe ]
|
Element |
Description |
Restrictions |
|
exp_ent |
Integer expression of the number of elements to read. |
0 < exp_ent < 2^31 |
|
liste_varia |
List of the variable_names to be read, separated by the character ','. |
Variables have a maximum of 1 dimension. |
|
class |
Abbreviation describing the open file. |
None |
# The TEST file starts with the sequence of letters in the alphabet: abcdefghijklmnopqrstuvwxyz
# Read from the 6th byte of this file, of 3 elements.
# These elements are placed in a string and a grid of character strings.
Char X(4), Y (5)(9)
Openi filpath("TXT", "TEST", ""), 5
Getseq 3, X, Y
Openi
#
# After this process:
|
x = |
"fghi" |
|
|
0 |
1 |
2 |
3 |
4 |
5 |
6 |
|
y = |
"jklmn" |
"opqrs" |
|
|
|
|
|
# As above, the TEST file starts with the sequence of letters in the alphabet:
# of the alphabet: abcdefghijklmnopqrstuvwxyz
Char Y(5) (2,3)
Openi filpath("TXT", "TEST", "")
Getseq 4, Y(0), Y(1)
#
# After this process:
|
|
0 |
1 |
2 |
|
y(0,.) |
'abcde' |
'fghij' |
'klmno' |
|
y(1,.) |
'pqrst' |
' ' |
' ' |
# the example below can also be written as follows
Char Y(5) (2,3)
Openi filpath("TXT", "TEST", "") Using [ZZZ]
Getseq 4, Y(0), Y(1)Using [ZZZ]
Getseq reads in the last file opened by Openi or Openio elements whose number is provided by exp_ent and copies them to the list of variables passed as arguments of the instruction.
The Using clause is used to specify the class of the sequential file that is being read. It is now possible to process several sequential files at the same time.
In the presence of grid elements in the list, the last dimension can be ignored. In case of single-dimension grids, the name of the grid can be specified without giving an index. The elements read in the file are copied to these variables in the ascending order of the index of the ignored dimension until the number of values to be read has been exhausted.
The elements are read based on the internal structure of the variables given as arguments. The following grid provides the format and byte number used according to the types of variables:
|
SIZE AND FORMAT OF THE INFORMATION WRITTEN BY PUTSEQ AND READ BY GETSEQ |
||
|
variable type |
Format on the sequential file |
Bytes |
|
Description |
In the form of a byte whose value ranges from 0 to 255. |
1 |
|
Char |
In the form of a byte whose value ranges from 0 to 255. |
1 |
|
Shortint |
A short integer signed over 2 bytes in the upper part and lower part order. |
2 |
|
Date defined in a class [F] |
The number of days on 3 bytes starting with the highest part. |
3 |
|
Date defined in another class |
The number of days on 4 bytes starting with the highest part (like Integer). |
4 |
|
Integer |
An integer signed on 4 bytes starting with the upper part. |
4 |
|
Float |
Float with the machine format |
often 4 |
|
Double |
Double precision with the machine format. |
often 8 |
|
SIZE AND FORMAT OF THE INFORMATION WRITTEN BY PUTSEQ AND READ BY GETSEQ |
||
|
variable type |
Format on the sequential file |
Bytes |
|
Decimal n.m defined in a class [F] |
The number with DCB C-Isam format. |
(n+m+e+3)/2 |
|
Decimal defined in another class |
The number with DCB C-Isam format with the maximum precision. |
16 |
As shown in this grid, the Date type variables have a 3-byte size in the class [F] (the purpose being to take as little space as possible in the database), whereas in the class [V] or [L], they take the space of a long integer. In the same way, decimal numbers are automatically declared with a maximum size if they are declared elsewhere than in the tables. The write of Float or Double type variables creates a non-portable file (as it is the case for Decimal type variables defined in a class other than [F]).
It is possible to read a text file (Blob) (and an image file, or Clob) from a sequential file using the Getseq instruction.
The fstat Adonix system variable is set to 1 if the read has encountered the end of the file.
Those variables that could not be impacted by the Getseq instruction, either because the end of the file had been reached or because the number of elements read was lower the the number of elements passed as arguments, are reset to zero.
If the number of elements to be read is higher than the total number of elements passed as arguments, no error is displayed.
The adxseek(0) or adxseek(class) function (for a file open with a class) mentions at any moment the position (in number of bytes) with respect to the beginning of the file. It is equal to 1 if no file has been open in read mode.
|
Error |
Description |
|
ERMODE (10) |
exp_ent is not of the integer type. |
|
ERDIM (55) |
Variable with more than one dimension |
OPENI - OPENIO - SEEK - ADXSEEK - PUTSEQ - RDSEQ - WRSEQ - FSTAT
|
Copyright © Sage 1999 - 2007 |