•  Back 
  •  Main 
  •  Index 
  •  Tree View 
  •  Cross references 
  •  Help 
  •  Show info about hypertext 
  •  View a new file 
Topic       : The GFA-Basic Compendium
Author      : GFA Systemtechnik GmbH
Version     : GFABasic.HYP v2.98 (12/31/2023)
Subject     : Documentation/Programming
Nodes       : 899
Index Size  : 28056
HCP-Version : 3
Compiled on : Atari
@charset    : atarist
@lang       : 
@default    : Document not found
@help       : Help
@options    : +g -i -s +z
@width      : 75
@hostname   : STRNGSRV
@hostname   : CAB     
@hostname   : HIGHWIRE
@hostname   : THING   
View Ref-FileSEEK #n,pos
RELSEEK #n,num

n, num, pos: iexp

The commands SEEK and RELSEEK permit the re-positioning of the data pointer
with an accessed file, allowing the realisation of indexed sequential file
access. The numerical expression n contains the channel number used when the
file was OPENed. Both commands can be used only with files, not with peripheral
devices. The data pointer specifies which byte of a file was read or written
last. Except for access mode 'A' (used to append data to the end of an existing
file) the data pointer has the value 0 when opening a file. Reading or writing
commences with first byte, to which the data pointer subsequently points.

The SEEK command positions the data pointer to a specified byte number in a
file. The pointer can, however be moved a specified number of bytes forwards or
backwards with RELSEEK (relative seek): the pointer is moved the number of
bytes specified in num. RELSEEK is generally faster than SEEK.

SEEK may use positive values of pos up to the relevant file length. RELSEEK
accepts positive or negative values of num, an error occurring when an attempt
is made to position the data pointer past the end or before the beginning of a
file. SEEK #n,0 takes the pointer to the start of a file.

Example:

    OPEN "o",#1,"X.X"
    PRINT #1,STRING$(20,"*")
    SEEK #1,10
    PRINT #1,"#";
    RELSEEK #1,-5
    OUT #1,48,49
    CLOSE #1
    '
    OPEN "i",#1,"X.X"
    LINE INPUT #1,a$
    CLOSE #1
    PRINT a$

--> Displays: ******01**#*********

Memo: FSEEK does not issue and error when compiled if the #channel is
      wrong.

      SEEK can accept negative values. The offset then specifies the number of
      bytes from the end of the file.  Seems to be an undocumented feature.
      However, you can't actually reach the exact end of the file as -0 isn't
      a valid number.

Fseek()+