Adxseek

adxseek returns the position of the read / write pointers on sequential files.

Syntax

adxseek(INTEGER_EXPR)adxseek (STRING_EXPR)

Examples

# Subprogram copying a file containing text lines (end of line is line feed)# Copy every line in the new file preceded by the position in the original file (in bytes)# Ignore a final line if not followed by line feed# Return the size of the file copied at the endSubprog COPYFILE(PATH1,PATH2,FILE_SIZE)Variable Char PATH1(),PATH2()Variable Integer FILE_SIZELocal Integer ILocal Char BUFFER(250)Openi PATH1,0Openo PATH2,0adxifs = '' : adxirs = chr$(10) : I = 1RepeatI=adxseek(0) Rdseq BUFFERIf fstat=0Wrseq "["+num$(I)+"]";Wrseq BUFFEREndifUntil fstat=0I=adxseek(1)Openi : OpenoEnd I# The same program, but with an abbreviation set on both open (INP for input, OUT for output)Subprog COPYFILE(PATH1,PATH2,FILE_SIZE)Variable Char PATH1(),PATH2()Variable Integer FILE_SIZELocal Integer ILocal Char BUFFER(250)Openi PATH1,0 Using [INP]Openo PATH2,0 Using [OUT]Iomode adxifs '' Using [INP] : Iomode adxirs chr$(10) Using [INP]Iomode adxifs '' Using [OUT] : Iomode adxirs chr$(10) Using [OUT]RepeatI=adxseek("INP") Rdseq BUFFER Using [INP]If fstat=0Wrseq "["+num$(I)+"]"; Using [OUT]Wrseq BUFFER Using [OUT]EndifUntil fstat=0I=adxseek("OUT")Openi Using [INP] : Openo Using [OUT]End I

Description

When a file is opened without abbreviation, the read pointer, that is the position difference in (bytes) between the beginning of the file and the place where the next information is read, is returned by adxseek(0). If no file is opened, adxseek(0) returns 0.

For a file opened without abbreviation, the write pointer, that is the position difference in (bytes) between the beginning of the file and the place where the next information is written, is returned by adxseek(1). If no file is opened, adxseek(1) returns 0.

If Openio has been used without abbreviation, adxseek(0) and adxseek(1) have always the same value.

For a file opened with the [abbrev] abbreviation, the read or write pointer is retrieved by adxseek("abbrev").

The adxseek(0) or adxseek("abbrev") if the file is opened in read mode, can be modified:
- By a read operation (Rdseq, Getseq).
- By a Seek operation.

The adxseek(1) or adxseek("abbrev") can be modified if the file is opened in write mode:
- By a write operation (Wrseq, Putseq).
- By a Seek operation only if the file is opened in read/write mode (Openio).

These variables cannot be modified by an assignment.

See also

Openi, Openo, Openio, Seek, Rdseq, Wrseq, Getseq, Putseq, Iomode, adxifs, adxirs.