PUTSEQ |
Putseq is used to write data from variables in a binary file opened by Openo or Openio.
Putseq exp_ent, varia_list [ Using class ]
|
Element |
Description |
Restrictions |
|
exp_ent |
Integer expression of the number of elements to write. |
None. |
|
liste_varia |
List of the variable_names to be written, separated by the character ','. |
Variables have a maximum of 1 dimension. |
|
class |
Abbreviation describing the open file. |
None |
# Write in the TEST file of 5 elements of an array of
# character strings. If a character string presents a length
# smaller than the one that was declared, it will be completed in the
# file by nul bytes (of ascii 0 code)
Char Y (6) (4,3)
Openo filpath("TXT", "TEST", "")
Putseq 5 Y(0), Y(1,2), Y(2)
Openo
#
# Let us assume that, in this example, the variable Y is initialized
# as follows:
|
|
0 |
1 |
2 |
|
Y (0, .) |
zero |
Zero |
ZERO |
|
Y (1, .) |
one |
Un |
ONE |
|
Y (2, .) |
two |
Two |
TWO |
# After the process, the TEST file contains 30 characters
# (including nul bytes (represented by a "n"):
|
|
1 |
2 |
3 |
4 |
5 |
|
Elements |
zeronn |
Zeronn |
ZEROnn |
Onennn |
twonn |
# the example above can also be written as follows
Char Y (6) (4,3)
Openo filpath("TXT", "TEST", "")Using [ZZZ]
Putseq 5 Y(0), Y(1,2), Y(2) Using [ZZZ]
Openo Using [ZZZ]
Putseq writes, in the last file opened by Openo or Openio, the elements contained in the list of variables passed as arguments of the instruction, the number of these elements being given by exp_ent.
The Using clause is used to specify the class of the sequential file that is being written. 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 of these variables are then read in the ascending order of the index of the ignored dimension and copied to the file until the number of values to be written has been exhausted.
The elements are copied to the file based on the internal structure of the variables given as arguments. The following grid provides the format and byte number used according to the type 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 |
|
Decimal n.m defined in a class [F] |
The number with DCB C-Isam format. |
(n+m+e+3)/2 m even: e=0 m odd: e=1 |
|
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 other classes, they take the space of a long integer. Similarly, the decimal numbers are automatically declared with a maximum size if they are declared elsewhere than in the tables. The write of Decimal type variables defined in a class other than [F] creates a non-portable file.
It is possible to write a text file (Blob) (and an image file, or Clob) to a sequential file using the Putseq instruction. The sequential file will have a length equal to that of the text file (blob).
The adxseek(1) or adxseek(class) functions (for a file open with a class) contain after the write the current position in the file, expressed in bytes. This variable is equal to -1 if no file has been opened in write mode.
Since the writes in a file are buffered, they are only effective after said file has been closed by the Openo or Openio instructions. It means that, before the operation, the size of the file on the disk can be unchanged after a Putseq. Seek 0 makes it possible to force the write of a file that has been opened by Openio.
The Putseq instruction is used to create ascii or binary files with any kind of structure.
|
Error |
Description |
|
ERMODE (10) |
exp_ent is not of the integer type. |
|
ERDIM (55) |
Variable with more than one dimension |
|
ERGFIC (24) |
Error in the management of the sequential file |
|
ERMDISK (44) |
No space available any longer on the disk. |
|
ERULIM (65) |
ulimit problem (the file is too big). |
GETSEQ - RDSEQ - WRSEQ - ADXSEEK - SEEK - OPENO - OPENIO
|
Copyright © Sage 1999 - 2007 |