Difference between revisions of "GET"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
(Created page with 'The '''GET''' file statement reads data from a BINARY or RANDOM file by bytes or TYPE variable records. ''Syntax:'' GET #1, location, variable ''See also:'' [[…')
 
imported>Clippy
Line 1: Line 1:
The '''GET''' file statement reads data from a [[BINARY]] or [[RANDOM]] file by bytes or TYPE variable records.
+
The '''GET''' file statement reads data from a file by bytes or TYPE variable records.
  
  
  
''Syntax:'' GET #1, location, variable
+
''Syntax:'' GET #filenumber%, [location], variable_value
  
  
 +
 +
* File number is the number of the file [[OPEN]] AS statement.
 +
* The byte or record location is the byte in a [[BINARY]] file or the record in a [[RANDOM]] file.
 +
* Location can be omitted if the GETs are consecutive or when creating a new file.
 +
* The variable value is any string or number type or a [[TYPE]] or [[FIELD]]variable.
 +
 +
 +
 +
''Example:'' Using a TYPE record variable to read a record.
 +
 +
: OPEN file$ FOR RANDOM as #1 LEN = LEN(Contact)
 +
: IF record% <= [[LOF]](1) \ LEN(Contact) THEN GET #1, record%, Contact
 +
: CLOSE #1
 +
 +
''Note:'' The Contact record contains all variable types listed in the TYPE.
  
  

Revision as of 07:50, 5 September 2009

The GET file statement reads data from a file by bytes or TYPE variable records.


Syntax: GET #filenumber%, [location], variable_value


  • File number is the number of the file OPEN AS statement.
  • The byte or record location is the byte in a BINARY file or the record in a RANDOM file.
  • Location can be omitted if the GETs are consecutive or when creating a new file.
  • The variable value is any string or number type or a TYPE or FIELDvariable.


Example: Using a TYPE record variable to read a record.

OPEN file$ FOR RANDOM as #1 LEN = LEN(Contact)
IF record% <= LOF(1) \ LEN(Contact) THEN GET #1, record%, Contact
CLOSE #1

Note: The Contact record contains all variable types listed in the TYPE.




See also: PUT

Navigation:

Go to Keyword Reference - Alphabetical

Go to Keyword Reference - By usage