This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!
Get Function
Reads data from an open disk file into a .
Get (channel, value, recordnumber)
Arguments
- channel
- Required. Any valid .
- value
- Required. Valid variable name into which data is read.
- recordnumber
- Optional. Record number (Random mode files) or byte number (Binary mode files) at which reading begins.
Remarks
Data read with Get is usually written to a file with Put.
The first record or byte in a file is at position 1, the second record or byte is at position 2, and so on. If you omit recordnumber, the next record or byte following the last Get or Put (or pointed to by the last Seek function) is read.
Question: How much of the following text remains true?
You must include delimiting commas, for example:
Get
#4,,FileBuffer
For files opened in Random mode, the following rules apply:
- If the length of the data being read is less than the length specified in the Len clause of the Open statement, Get reads subsequent records on record-length boundaries. The space between the end of one record and the beginning of the next record is padded with the existing contents of the file buffer. Because the amount of padding data can't be determined with any certainty, it is generally a good idea to have the record length match the length of the data being read.
- If the variable being read into is a variable-length string, Get reads a 2-byte descriptor containing the string length and then reads the data that goes into the variable. Therefore, the record length specified by the Len clause in the Open statement must be at least 2 bytes greater than the actual length of the string.
- If the variable being read into is a dynamic array, Get reads a descriptor whose length equals 2 plus 8 times the number of dimensions, that is, 2 + 8 * NumberOfDimensions. The record length specified by the Len clause in the Open statement must be greater than or equal to the sum of all the bytes required to read the array data and the array descriptor. For example, the following array declaration requires 118 bytes when the array is written to disk.
Dim MyArray(1 To 5,1 To 10) As Integer
The 118 bytes are distributed as follows: 18 bytes for the descriptor (2 + 8 * 2), and 100 bytes for the data (5 * 10 * 2).
- If the variable being read into is a fixed-size array, Get reads only the data. No descriptor is read.
- If the variable being read into is any other type of variable (not a variable-length string or an Object), Get reads only the variable data. The record length specified by the Len clause in the Open statement must be greater than or equal to the length of the data being read.
- Get reads elements of as if each were being read individually, except that there is no padding between elements. On disk, a dynamic array in a user-defined type (written with Put) is prefixed by a descriptor whose length equals 2 plus 8 times the number of dimensions, that is, 2 + 8 * NumberOfDimensions. The record length specified by the Len clause in the Open statement must be greater than or equal to the sum of all the bytes required to read the individual elements, including any arrays and their descriptors.
For files opened in Binary mode, all of the Random rules apply, except:
Question: How much of the text above remains true?…in case you forgot my asking this the first time…
See Also
Example
Open Statement | Put Statement | Seek Function