SEEK |
Seek is used to move the read pointer from a file opened with Openi or Openio.
Seek is also used (with a null value) to force a write on the file (flush).
Seek First + exp_e
[ Using class
]
Seek Last - exp_e
[ Using class
]
Seek Curr + exp_e
[ Using class
]
Seek Curr - exp_e
[ Using class
]
Seek exp_e [ Using class ]
|
|
Description |
Restrictions |
|
exp_e |
Integer expression containing the value of the shift to be made |
None |
|
class |
Abbreviation indicating an open file. |
None. |
# Open a file, and read 10 octets out of every 20 octets
Char BUFFERS(10)(MAXLIGNES) Openi "FICHIER" fstat = 0 : I = 0 Repeat Getseq 1, BUFFERS(I) : I += 1Seek 10
Until fstat <> 0 or I >= MAXLIGNES Openi# Rewrite the last 50 octets of a file
Libelle BUFFER(50) Openio "FICHIER"Seek Last - 50
Getseq 50, BUFFER# .. Modification of BUFFER
Seek Last - 50
Putseq 50, BUFFER Openio# If 2 files are open:
# Rewrite the last 50 octets of the 2nd file Libelle BUFFER(50) Openi "FICHIER1" Using [YYY] Openi "FICHIER2" Using [ZZZ]Seek Last - 50 Using [ZZZ]
Getseq 50, BUFFER Using [ZZZ] Openi Using [ZZZ] Openi Using [YYY]# Write 1 octet with "flush"
Putseq 1, UN_OCTETSeek 0
Seek is used to move the read or read/write pointer for a file opened with Openi or Openio. You can move:
· with respect to the start of the file (syntax "Seek First + exp_e"),
· with respect to the end of the file (syntax "Seek Last - exp_e"),
· with respect to the current position (syntax "Seek Curr + exp_e").
In the syntax "Seek exp_e", the move is made with respect to the current position.
On some files (such as pipes, or particular devices), the Seek is impossible. In this case an ERSEEK error is returned.
The syntax "Seek 0", or Seek (which is the same as a non-movement of the pointer) flushes the write buffers since the write functions are all buffered. This syntax can therefore be used on all types of file; if no file was opened in write mode, it does not cause an error, but it does nothing.
The adxseek(0) or adxseek(class) (for a file opened with a class) functions are used to give the current position (in number of octets) at any time with respect to the start of the file. This variable equals –1 if no sequential file was opened in read mode, but it is updated even if it is impossible to do a Seek on the file (in this case, its initial value is 0 and it is incremented by the number of bytes read or written).
|
Error |
Description |
|
ERMODE (10) |
The argument is not a numerical type. |
|
ERDOM (50) |
The argument is not an integer type. |
|
ERGFIC (24) |
No file open in Openi or Openio. |
|
ERSEEK (57) |
Seek impossible on this type of file. |
OPENI - OPENIO - ADXSEEK - RDSEQ - WRSEQ - GETSEQ - PUTSEQ
|
|