6.1.2.7 Information
Note
This section describes the implementation of MS-VBAL §6.1.2.7 Information.
The Information module is represented in the language core by the interface
IStdInformationModule.
The Information module is declared in full: every member of MS-VBAL §6.1.2.7 has a declaration in
IStdInformationModule, and so does each of the two RD-VBA additions, Erl and Err. The module's symbols are read
off those declarations (RD-VBAL §6.0 Standard Library).
Every member has a runtime implementation (StdInformation).
6.1.2.7.1 Public Functions
Note
This section describes the implementation of MS-VBAL §6.1.2.7.1 Public Functions.
Erl and Err are not members MS-VBAL lists under this module. They are numbered after the last MS-VBAL member of
this section.
| § | Member | Notes |
|---|---|---|
| 6.1.2.7.1.1 | IMEStatus | |
| 6.1.2.7.1.2 | IsArray | |
| 6.1.2.7.1.3 | IsDate | |
| 6.1.2.7.1.4 | IsEmpty | |
| 6.1.2.7.1.5 | IsError | |
| 6.1.2.7.1.6 | IsMissing | In MS-VBA, always False for a non-Variant parameter. See RD-VBAL §5.3.1.11 Procedure Invocation Argument Processing. |
| 6.1.2.7.1.7 | IsNull | |
| 6.1.2.7.1.8 | IsNumeric | |
| 6.1.2.7.1.9 | IsObject | |
| 6.1.2.7.1.10 | QBColor | |
| 6.1.2.7.1.11 | RGB | |
| 6.1.2.7.1.12 | TypeName | |
| 6.1.2.7.1.13 | VarType | Declared to return a VbVarType value. See RD-VBAL §6.1.1 Predefined Enums. |
| 6.1.2.7.1.14 | Erl |
RD-VBA addition. See §6.1.2.7.1.14. |
| 6.1.2.7.1.15 | Err |
RD-VBA addition. See §6.1.2.7.1.15. |
6.1.2.7.1.14 Erl
Information.Erl is an RD-VBA addition to MS-VBAL. Erl returns the line number at which the most recent
run-time error was raised.
MS-VBAL does not document Erl. MS-VBA exposes Erl from the Information module as a hidden member.
Erl is a deliberate RD-VBA departure from MS-VBA, in three respects: what it counts, what Err.Clear does to it,
and its width.
What Erl counts
MS-VBA's Erl reports the last line-number label execution passed. A fault in an unnumbered statement is reported at
the nearest preceding numbered line. A program that numbers no lines gets 0 for every error.
MS-VBA's Erl reports the faulting line only when every line is numbered.
What RD-VBA's Erl counts is a setting of the environment, ErlLineNumbering, a member of
IRuntimeEnvironmentProfile.
ErlLineNumbering is bound from appsettings.json, like the rest of the runtime profile
(RD-VBAL §2.1 Implicit Storage).
ErlLineNumbering mode (VBErlLineNumbering) |
Erl reports |
|---|---|
DocumentLine (the default) |
The document line of the faulting statement, counted from 1 as an editor counts it. |
LineLabel |
The last line-number label at or before the faulting statement, or 0 when no line-number label precedes it. This matches MS-VBA's Erl. |
The faulting statement is a statement of the procedure whose handler catches the error. For an error a procedure it calls raised, it is the
call, in both modes, as in MS-VBA: Erl reports the call's line, or the last line-number label before the call.
A named label never sets Erl, in either ErlLineNumbering mode. Only a label spelled as decimal digits sets Erl
(RD-VBAL §5.4.1.1 Statement Labels).
In a program that numbers every line, the line-number label is the document line, and LineLabel reports it.
LineLabel mode exists for a workspace whose own code depends on MS-VBA's Erl behaviour.
After Err.Clear
In MS-VBA, Err.Clear resets the error's number and the other properties of the error object, but Erl keeps
reporting the line of the error it cleared. Every other way an error is cleared resets Erl to 0: a Resume
statement in any form, an On Error statement, and leaving the procedure from an error handler.
Leaving a procedure under On Error Resume Next, at its end or by an Exit statement, clears no error. The caller sees
the error and its line as the procedure left them: after 20 x = 1 / 0, Erl is 20 and Err.Number is 11. After
an Err.Clear in the procedure, the caller sees what Err.Clear left: Err.Number is 0, and Erl is as
ErlAfterErrClear says.
What Err.Clear does to Erl is a second environment setting, ErlAfterErrClear, bound from appsettings.json like
ErlLineNumbering. It applies to Err.Clear only.
ErlAfterErrClear value (VBErlAfterErrClear) |
Erl after Err.Clear |
|---|---|
Reset (the default) |
0, as there is no error any more. |
Kept |
The line of the error Err.Clear cleared. This matches MS-VBA's Erl. |
Width
MS-VBA's Erl has ushort resolution. It wraps around on any line number that does not fit, so for a program
numbered past line 65535 it reports a line that does not exist.
For this reason, RD-VBA's Erl returns a Long, in which every legal line number is representable.
Implementation
The line number Erl reports is carried on
ISessionErrorState.LineNumber. It is
captured at the one point where every run-time error reaches the session error state: the interpreter's
error-interception point (RD-VBAL §3.5.4 Execution).
In LineLabel mode, InstructionList.TryGetLineNumber
provides the line number Erl reports (RD-VBAL §3.5.1 InstructionList).
6.1.2.7.1.15 Err
Err is not a member MS-VBAL lists under this module. RD-VBA implements the MS-VBA shape of Err: a zero-argument
Function of the Information module, returning an instance of the class ErrObject.
The Err function, the ErrObject class, and the MS-VBAL shape they differ from are described in
RD-VBAL §6.1.3.2 Err Class.