Difference between revisions of "SEEK (statement)"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
(Created page with 'The '''SEEK''' statement sets the next byte or record position of a file for a read or write. ''Syntax:'' SEEK filenumber%, position% * The filenumber must be a file that i…')
 
imported>Cyperium
m
 
(13 intermediate revisions by one other user not shown)
Line 3: Line 3:




''Syntax:'' SEEK filenumber%, position%
{{PageSyntax}}
:: SEEK ''filenumber&'', ''position''






* The filenumber must be a file that is [[OPEN]].
* ''filenumber'' must be the file number that is [[OPEN]] and being read or written to.
* Position is a byte in [[BINARY]] or sequencial files.
* ''position'' is a byte in [[BINARY]] or sequencial files created in [[OUTPUT]], [[APPEND]] or [[INPUT (file mode)]]s. The first byte = 1.
* Position is the record in [[RANDOM]] files to read or write.
* ''position'' is the record in [[RANDOM]] files to read or write. Records can hold more than one variable defined in a [[TYPE]].
* Since the first SEEK file position is 1 it may require adding one to an offset value when documentation uses that position as 0.
* After a SEEK statement, the next file operation starts at that SEEK byte position.
* The SEEK statement can work with the [[SEEK]] function to move around in a file.
* The SEEK statement can work with the [[SEEK]] function to move around in a file.




''Example:'' A SEEK statement moving to the next random record in a file.
''Example:'' A SEEK statement using the [[SEEK]] function to move to the next random record in a file.


: SEEK 1, SEEK(1) + 1
{{CodeStart}}
SEEK 1, {{Cl|SEEK}}(1) + 1
{{CodeEnd}}






==Navigation:==
''See also:''
* [[SEEK]] {{text|(function)}}
* [[GET]], [[PUT]]


[[Keyword_Reference_-_Alphabetical|Go to Keyword Reference - Alphabetical]]


[[Keyword Reference - By usage|Go to Keyword Reference - By usage]]
{{PageNavigation}}

Latest revision as of 02:57, 6 February 2014

The SEEK statement sets the next byte or record position of a file for a read or write.


Syntax

SEEK filenumber&, position


  • filenumber must be the file number that is OPEN and being read or written to.
  • position is a byte in BINARY or sequencial files created in OUTPUT, APPEND or INPUT (file mode)s. The first byte = 1.
  • position is the record in RANDOM files to read or write. Records can hold more than one variable defined in a TYPE.
  • Since the first SEEK file position is 1 it may require adding one to an offset value when documentation uses that position as 0.
  • After a SEEK statement, the next file operation starts at that SEEK byte position.
  • The SEEK statement can work with the SEEK function to move around in a file.


Example: A SEEK statement using the SEEK function to move to the next random record in a file.

SEEK 1, SEEK(1) + 1


See also:



Navigation:
Keyword Reference - Alphabetical
Keyword Reference - By Usage
Main Wiki Page