Table of Contents

3.4.3 File Statements

MS-VBAL groups the file I/O statements under one umbrella section, MS-VBAL §5.4.5 File Statements. Each file statement is cross-referenced below to its MS-VBAL section and to the RD-VBAL page that describes its implementation; see also RD-VBAL §5.4.5 File Statements.

Statement Node type MS-VBAL RD-VBAL
Open OpenStatementNode; see Open Statement MS-VBAL §5.4.5.1 Open Statement RD-VBAL §5.4.5.1 Open Statement
Close, Reset KeywordStatementNode (Token: Close or Reset) MS-VBAL §5.4.5.2 Close and Reset Statements RD-VBAL §5.4.5.2 Close and Reset Statements
Seek KeywordStatementNode (Token: Seek) MS-VBAL §5.4.5.3 Seek Statement RD-VBAL §5.4.5.3 Seek Statement
Lock FileLockStatementNode (Token: Lock); see Lock and Unlock Statements MS-VBAL §5.4.5.4 Lock Statement RD-VBAL §5.4.5.4 Lock Statement
Unlock FileLockStatementNode (Token: Unlock) MS-VBAL §5.4.5.5 Unlock Statement RD-VBAL §5.4.5.5 Unlock Statement
Line Input # KeywordStatementNode (Token: "Line Input") MS-VBAL §5.4.5.6 Line Input Statement RD-VBAL §5.4.5.6 Line Input Statement
Width # KeywordStatementNode (Token: Width) MS-VBAL §5.4.5.7 Width Statement RD-VBAL §5.4.5.7 Width Statement
Print # (file-number form) PrintStatementNode (Token: Print) MS-VBAL §5.4.5.8 Print Statement RD-VBAL §5.4.5.8 Print Statement
Owner.Print (object-qualified form) ObjectPrintExpressionNode MS-VBAL §5.4.5.8 RD-VBAL §5.4.5.8 Print Statement
Debug.Print DebugPrintStatementNode MS-VBAL §5.4.5.8 RD-VBAL §5.4.5.8 Print Statement
Write # PrintStatementNode (Token: Write) MS-VBAL §5.4.5.9 Write Statement RD-VBAL §5.4.5.9 Write Statement
Input # KeywordStatementNode (Token: Input) MS-VBAL §5.4.5.10 Input Statement RD-VBAL §5.4.5.10 Input Statement
Put # KeywordStatementNode (Token: Put) MS-VBAL §5.4.5.11 Put Statement RD-VBAL §5.4.5.11 Put Statement
Get # KeywordStatementNode (Token: Get) MS-VBAL §5.4.5.12 Get Statement RD-VBAL §5.4.5.12 Get Statement
Name KeywordStatementNode (Token: Name) Not specified. RD-VBAL §5.4.5.13 Name Statement

Open Statement

OpenStatementNode's Mode, Access and Lock are keyword choices, not expressions. They are typed VBFileMode, VBFileAccessMode and VBFileLockMode.

Lock and Unlock Statements

Lock and Unlock have an AST node of their own, FileLockStatementNode, because their record-range (MS-VBAL §5.4.5.4) has three shapes and a flat input list could tell only two of them apart:

record-range = start-record-number / ([start-record-number] "To" end-record-number)

Lock #1, 5 locks record 5, and Lock #1, To 5 locks records 1 through 5. Each carries one expression, so a flat input list cannot distinguish them. FileLockStatementNode's StartRecord and EndRecord are therefore named properties rather than positional inputs:

Statement StartRecord EndRecord
Lock #1, 5 5 null
Lock #1, 2 To 5 2 5
Lock #1, To 5 null 5

An absent start-record-number stays absent in FileLockStatementNode: the node does not fill in 1. MS-VBAL says of an absent start-record-number: "the effect is as if <start-record-number> consisted of the integer number token 1". The implied start record 1 is a runtime semantic, not something the program wrote, so the node does not model it; see RD-VBAL §5.4.5.4 Lock Statement.

Output Lists

PrintStatementNode, ObjectPrintExpressionNode and DebugPrintStatementNode share one output-list shape (MS-VBAL §5.4.5.8.1 Output Lists):

Node Represents
PrintOutputItemNode An output item: a value and/or a ; or , separator.
PrintSpcClauseNode A Spc clause.
PrintTabClauseNode A Tab clause.
Tip

In a parsed output list, a value and its trailing separator are always two separate, alternating PrintOutputItemNodes: one value-only, one separator-only. MS-VBAL's outputItem grammar rule admits combining a value and its separator into one output item, but the generated parser never takes that alternative. A consumer of Items should walk the alternating list rather than assume (value, separator) pairs.

Note

Not implemented. The ? shorthand for Print has no lexer or grammar token.


⏮️ RD-VBAL §3.4.2 Simple Statements | ⏭️ RD-VBAL §3.5.0 Instructions