5.4.5.12 Get Statement
Note
This section describes the implementation of MS-VBAL §5.4.5.12 Get Statement.
Syntax
| AST node | Instruction kind(s) | Notes |
|---|---|---|
| KeywordStatementNode | Simple |
Token: Get. |
See RD-VBAL §3.4.3 File Statements.
Runtime Semantics
Get reads through the record surface of a file channel, which it shares with Put
(RD-VBAL §5.4.5 File Statements).
Get resolves its target with the same target resolution the Let assignment statement uses
(RD-VBAL §5.4.3.8 Let Statement). It Let-assigns what it reads to its
target, as MS-VBAL §5.4.5.12 specifies.
Record Format
Get reads the record format Put writes:
MS-VBAL §5.4.5.11 Put Statement's
Variant type descriptors and binary widths. The format is a wire format rather than a behaviour, and follows
MS-VBA's so that a file RD-VBA writes is a file MS-VBA reads. See
RD-VBAL §5.4.5.11 Put Statement for the format.
Get reads each member of a UDT in declaration order, recursively through a nested UDT. Get moves the
serialized size of a UDT. Put #1, , myRecord and Get #1, , myRecord serialize and deserialize a whole UDT in
one statement.
| Target | What Get reads |
|---|---|
A fixed-size array, or a resizable array in Binary mode |
As many elements as the array's bounds give, into the array. An array that was never sized reads nothing. |
A resizable array in Random mode |
The bounds the record gives. The array is sized to them, then its elements are read as its declared element type. |
Past the End of the File
A Get that runs past the end of the file raises no error, as in MS-VBA (recorded in Excel). Each byte the file
does not have reads as zero, and the file-pointer-position moves past the whole record. EOF is then True.
Record Positioning
Get positions records as Put does
(RD-VBAL §5.4.5.11 Put Statement):
- Record number 1 is byte 0 of the file. The record number and the file-pointer-position are one quantity, and
SeekandGetmust agree on it (RD-VBAL §5.4.5.3 Seek Statement). - A
Randomchannel whoseOpenstatement declared noLenclause counts positions in 128-byte records.
Implementation
| Name | Role |
|---|---|
| IFileChannel | A file channel. Its record surface is the one Put and Get use. |
RecordDataFormat |
Implements the Put/Get record format. |
LetAssignmentEvaluator.TryResolveTarget |
Resolves the target: the same target resolution Input #, Line Input # and the Let assignment statement use. |