Getseq

Getseq reads data from a binary file opened by Openi or Openio.

Syntax

 Getseq INTEGER_EXPR, VAR_LISTGetseq INTEGER_EXPR, VAR_LIST Using [CLASS]

Examples

 # First example: let's read strings in a binary file# The lines have a constant length of 10# They are padded by 0Local Schar WORDS(5)(1..20)Openi "MYFILE",0 Using [DMP]Getseq 5,WORDS Using [DMP]Getseq 3,WORDS(8..12) Using [DMP]Openi Using [DMP]# Only the indexes 1 to 5, and 8 to 10 have been read.# The indexes 11 and 12 have been set to empty strings# Second example: let's red a blob in a fileGetseq 1,MYBLOB # Third example : Read a multi-dimensional arrays of IntegersLocal Integer ARRAY(1..5,1..10,1..5,1..4)Openi "dumpfile",0# If the whole array needs to be read:# Getseq NUMBER,ARRAY will fail (only one unspecified dimension can be given)# Let's perform loopsFor I=1 to dim(ARRAY,1)For J=1 to dim(ARRAY,2)For K=1 to dim(ARRAY,3)Getseq dim(ARRAY,4),ARRAY(I,J,K)Next KNext JNext I

Description

Getseq allows reading ASCII or binary files that have any content.

Getseq reads from a file and fills a number of elements given by the first argument on the list and by using these variables until the number of elements to be filled is reached. An element is either a single variable or an element of an array.

The elements are transferred from the file into the variable based on the format of the data given as an argument. The following array provides the format and the number of bytes written according based on the data type used, as indicated in the following table:

Data typeFormatNumber of bytes read
TinyIntByte.1 byte.
ScharCharacters on one byte in ASCII (padded with zeros).N bytes where N is the maximum size of the string.
ShortintShort integer in big Endian format.2 bytes.
Date variableNumber of days since the [31/12/1599] as an integer in big Endian format.4 bytes.
Date when defined in a [F] classNumber of days since the [31/12/1599] as a 3-byte integer in big Endian format.3 bytes.
Decimal value with format N.M when defined in a [F] classNumber in a BCD format that corresponds to the C-ISAM format.(N+M+E+3)/2 bytes, where E is 0 if M is even and 1 if M is odd.
Decimal value when defined as a variableNumber in a BCD format that corresponds to the C-ISAM format with the maximum precision.16 bytes.
CharCharacter string in UCS2 format.2*N bytes where N is the maximum size of the character string.
ClbfileThe contents of the CLOB padded by zeros.N bytes where N is the maximum size of the CLOB (N=1024 if the Clbfile has a (0) dimension, 2048 if Clbfile has a (1) dimension, and so forth).
Blbfile (binary data)The exact content of the BLOB.The exact size of the BLOB.
Uuident (unique id)UUID in canonical format.16 bytes.
DatetimeDate time stored as an integer in big Endian format.8 bytes.

Comments

The function adxseek(0) or adxseek("CLASS"), if the file has been opened with a class name, gives the position (in bytes, from the beginning of the file) where the next read operation will be done. The return value will be incremented every time a Getseq is performed. Its value is '-1' if no file has been opened for reading.

The system variable fstat is set to '1' if the read operation reached the end of the file.

The variables that cannot be assigned because the end of the file was reached or the number of elements is reached, are set to null values.

If the number of elements to be read is bigger than the total number of elements given as argument, no error occurs.

Associated errors

Error codeDescription
10INTEGER_EXPR is not an integer expression.
55Too many unspecified dimensions on variables written.

See also

Putseq, Rdseq, Wrseq, adxseek, Seek, Openi, Openo, Openio.