Difference between revisions of "GET"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
m
Line 11: Line 11:
 
* Location can be omitted if the GETs are consecutive or when creating a new 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.
 
* The variable value is any string or number type or a [[TYPE]] or [[FIELD]] variable.
 +
* '''QB64''' can GET the entire data contents of an array from a [[PUT]] array file.
  
  
  
''Example:'' Using a TYPE record variable to read a record.
+
''Example 1:'' Using a TYPE record variable to read a record.
  
 
: OPEN file$ FOR RANDOM as #1 LEN = LEN(Contact)
 
: OPEN file$ FOR RANDOM as #1 LEN = LEN(Contact)
Line 21: Line 22:
  
 
''Note:'' The Contact record contains all of the DOT variable types listed in the TYPE.
 
''Note:'' The Contact record contains all of the DOT variable types listed in the TYPE.
 +
 +
''Example 2:'' Restoring array data from a [[BINARY]] file using GET.
  
  

Revision as of 21:31, 6 January 2010

The GET # file or port statement reads data by bytes or record positions.


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


  • File/port number is the number used in the 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.
  • QB64 can GET the entire data contents of an array from a PUT array file.


Example 1: 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 of the DOT variable types listed in the TYPE.

Example 2: Restoring array data from a BINARY file using GET.




See also: PUT #, SEEK, SEEK (statement), INPUT #, GET (TCP/IP statement)


Navigation:

Go to Keyword Reference - Alphabetical

Go to Keyword Reference - By usage