OPENIO |
Openio is used to open and close a sequential file in read and write mode.
Openio [ exp_nomfic [, exp_depl ] ] [ Using abrev ]
|
Element |
Description |
Restrictions |
|
exp_nomfic |
Char type expresson 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, skipping the first 10
characters
Openio filpath('tmp','rdfile',''),
10
# Closing the last file opened for read and
write
Openio
# To read on the standard input medium
(keyboard)
# and write to the standard output
(screen)
Openio "*"
# Opening a file on the "distrib"
machine
Openio "distrib@"+[L]NOMFIC
# Opening file X3.ini on the client
Openio "#@C:\X3\X3.ini"
# Opening two files
Openio filpath('tmp','rdfile1','')
Using [YYY]
Openio
filpath('tmp','rdfile2','') Using [ZZZ]
# Closing two previously opened files
Openio Using [YYY]
Openio Using [ZZZ]
Openio is used to open a file for read or write with Rdseq, Wrseq, Putseq and Getseq.
The client station is conventionally indicated by the server #.
The value given in the 2nd parameter is used to start reading/writing at a given position in the file. If it is missing, read/write begins at the start of the file. In all cases, the Seek command is used to move about during read, and the adxseek(0), adxseek(1) or adxseek(abrev) functions give the position in the file. Obviously the file is not truncated, but it is expanded if writing goes on beyond the end of the file. If you carry out a Seek beyond the file, then write, the unwritten part of the file shall be filled with null characters.
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(0) and adxseek(1) functions give the position in the file. When the file was opened by Openio, these two functions always return an identical value.
· There may be only one sequential file opened by Openio and Openi or Openo at a given moment. Opening a file in read/write mode closes any file that may have been opened previously with Openio openi or openo.
· Openio used without a parameter closes the previously opened file or stops allocation from the input keyboard.
File with abbreviation:
· The adxseek(abrev) function gives the position in the file.
· 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.
· Openio, used with the using abrev clause only closes the file previously opened without this abbreviation.
If Openio is used with filename "*", the standard Adonix input device (in principle the keyboard) and the standard output device (in principle the screen) are assigned to an open file, allowing the characters to be read from the keyboard without decoding. Openio used without a parameter will stop this assignment.
Opening with Openio on a non-existent file does not create the file (unlike Openo which creates it if truncation is used or if you write at the end of the file) but causes the PAFIC error.
adxseek(0) is used for read positions and adxseek(1) for write positions. When the file was opened by Openio, these two values are always identical.
Writing to a file is buffered, and is thus only effective after the file has been closed by Openo or Openio. This means that prior to this operation, the file size on the disk is not changed after Putseq/Wrseq. The Seek 0 command may be used to empty the write buffers.
You should beware of conflicting accesses to a file opened by Openio. A symbol should be locked (see Lock) in order to manage problems of access to one file. It should be remembered that transactions do not apply to updates of sequential files.
|
Error |
Description |
|
ERMODE (10) |
exp_nomfic is not a Char type or exp_depl is not numerical. |
|
ERDOM (50) |
exp_depl < 0. |
|
ERACCE (27) |
Access impossible (permission refused). |
|
PAFIC (20) |
File (or path directory) non-existent. |
|
ERSEEK (57) |
The file is the standard input/output (exp_nomfic='*') and exp_depl <> 0. |
|
ERCHAN (60) |
Not enough channels available to open (where two are required). |
|
ERSYST (25) |
System error (connection problem with remote machine). |
OPENI - OPENO - SEEK - GETSEQ - PUTSEQ - RDSEQ - WRSEQ - ADXIFS - ADXIRS - ADXSEEK - ADXMAC - ADXMSO
|
|