OPENO |
Openo is used to open and close a sequential file in write-only.
Openo [ exp_nomfic [, exp_depl ] ] [ Using abrev ]
|
Element |
Description |
Restrictions |
|
exp_nomfic |
Char type expression whose result is a filepath (Unix or MS-DOS). |
None. |
|
exp_depl |
Numerical expression for the initial move value (seek). |
0 <= exp_depl <= size of file. |
|
abrev |
Abbreviation indicating an open file. |
None. |
# Opening a file for write operation with
preliminary truncation
Openo filpath('tmp','rdfile',''),
1024
# Closing the last file opened for write
Openo
# You want to write to the standard output
device (screen)
Openo "*"
# Creation of a file filled with null
octets!
NOMFIC = '/tmp/octets.nuls' : TAILLE = 100000
Openo
NOMFIC :#
Opening+creation if non-existent,truncation
Openo NOMFIC,
TAILLE :# Reopening, making it the correct size
# Opening a file on the "distrib"
machine
Openo "distrib@"+[L]NOMFIC
# Opening file X3.ini on the client
Openo "#@C:\X3\X3.ini"
# Opening two files
Openo filpath('tmp','rdfile1','')
Using [YYY]
Openo
filpath('tmp','rdfile2','') Using [ZZZ]
# Closing the two previously opened files
Openo Using [YYY]
Openo Using [ZZZ]
Openo is used to open a file for writing with Wrseq and Putseq.
The client station is conventionally indicated by the server #.
The value given in the 2nd parameter is used to truncate the file first to a given length before beginning the write operations, that is:
· if the value is null, the file is reduced to a null size;
· if the value is positive and less than the file size, the file is truncated to the given value; you can then write to the end of the file.
· if the value is negative (by agreement) or positive and greater than the filesize, the file is opened to add information, adding null octets as required to bring it up to the size matching the value (the file may only increase in size).
When it is opened, the adxseek(1) or adxseek(abrev) function contains the current position of the pointer, that is the current size of the file, that may be truncated.
The Using clause allocates an abbreviation to an open sequential file. Consequently, up to 7 sequential files may be opened simultaneously, subject to the value of the parameter adxmso.
File without abbreviation:
· The adxseek(1) function contains the current position of the pointer.
· There may be only one sequential file opened by Openo or Openio at a given moment. Opening a file in write mode closes any file that may have been opened previously with Openo or Openio.
· Openo used without a parameter closes the previously opened file or stops allocation from the output channel to the screen.
File with abbreviation:
· The adxseek(abrev) function contains the current position of the pointer.
· There may not be more than one file opened with the same abbreviation at a given moment. Opening a file with one abbreviation (including in a sub-programme) will close the file previously opened.
· Openo, used with the using abrev clause only closes the file previously opened without this abbreviation.
If Openo is used with filename '*', the standard Adonix output device (in principle the screen) is assigned to an open file, allowing the characters to be written on the screen without decoding.
In all cases, Openo keeps the file with all its links if any (it never deletes the file, but performs truncations). To remove links from the file if it exists, it has to be deleted or copied first (for example using the System instruction).
If no truncation parameter is given, Openo opens the file in add (exp_depl is negative by default).
Openo creates a file if there isn't one, only if it has been opened by truncation (exp_depl = 0) of for addition at the end of the file (exp_depl < 0). In other cases, the PAFIC error is initiated.
In order not to have to delete the file to be truncated, Openo copies the part of the file to be retained to a temporary file, then truncates the file to a null length and copies the temporary file to it. The Openo may therefore be long in execution (it cannot be interrupted by a soft break). In addition, you must check that there is enough disk space to copy the part of the file to be truncated. Otherwise, a 'No more disk space' error will occur. Similarly, opening a file to increase it to a size larger than its original size may take a long time and be a source of errors if there is not enough disk space, since Adonix writes null octets until it reaches the correct size.
You should beware of conflicting accesses to a file opened by Openo. A symbol should be locked (see Lock) in order to manage problems of access to one file by an Adonix application. You should be aware of the fact that transactions do not manage updates to sequential files.
Writing to a file is buffered, and is thus only effective after the file has been closed by the final Openo This means that prior to this operation, the file size on the disk is not changed after Wrseq/Putseq.
|
Error |
Description |
|
ERMODE (10) |
exp_nomfic is not a Char type or exp_depl is not numerical. |
|
ERDOM (50) |
The 2nd argument is not an integer. |
|
ERMDISK (44) |
No more disk space. |
|
ERACCE (27) |
Access impossible (permission refused). |
|
PAFIC (20) |
File (or path directory) non-existent. |
|
ERULIM (65) |
Max file size reached. |
|
ERCHAN (60) |
Not enough channels available to open (where one is required). |
|
ERSYST (25) |
System error (problem connecting to remote machine). |
OPENI - OPENIO - SEEK - GETSEQ - PUTSEQ - RDSEQ - WRSEQ - ADXIFS - ADXIRS - ADXSEEK - ADXMAC - ADXMSO
|
|