qb45advr.hlp (
Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
GET (File I/O) Statement Details
◄QuickSCREEN► ◄Details► ◄Example► ◄Contents► ◄Index►
──────────────────────────────────────────────────────────────────────────────
GET (File I/O) Statement Details
Syntax
GET [#]filenumber[,[recordnumber][,variable]]
Argument Description
filenumber The number used in the OPEN statement to open the
file.
recordnumber For random-access files, the number of the record
to be read. For binary-mode files, the byte position
in the file where reading starts. The first record or
byte position in a file is 1. If you omit
recordnumber, the next record or byte (the one after
the last GET or PUT, or the one pointed to by the
last SEEK) is read into the buffer. The largest
possible record number is 2^31 -1, or
2,147,483,647.
variable The variable used to receive input from the file. If
you use a variable, you do not need to use CVD, CVL,
CVI, or CVS to convert record fields to numbers. You
may not use a FIELD statement with the file if you
use the variable argument.
For random-access files, you can use any variable as
long as the length of the variable is less than or
equal to the length of the record. Usually, a record
variable defined to match the fields in a data record
is used.
For binary-mode files, you can use any variable. The
GET statement reads as many bytes as there are in the
variable.
When you use a variable-length string variable, the
statement reads as many bytes as there are characters
in the string's value. For example, the following two
statements read 10 bytes from file number 1:
VarStrings$=STRING$ (10, " ")
GET #1,,VarString$
See the examples for more information about using
variables rather than FIELD statements for random-
access files. A record cannot be longer than 32,767
bytes.
You may omit the recordnumber, the variable, or both. If you omit the
recordnumber but include the variable, you must still include the
commas:
GET #4,,FileBuffer
If you omit both arguments, you do not include the commas:
GET #4
The GET and PUT statements allow fixed-length input and output for
BASIC communications files. Use GET carefully because if there is a
communications failure, GET waits indefinitely for recordnumber
characters.
Note: When you use GET with the FIELD statement, you can use INPUT #
or LINE INPUT # after a GET statement to read characters from
the random-access file buffer. You may use the EOF function
after a GET statement to see if the GET went beyond the end
of the file.