vba-interpreter 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2015 @@
1
+ /** A container a copy walks: an array's elements or a UDT's fields. */
2
+ interface CopySlots {
3
+ /** A new container of the same shape whose slots are the same values (not yet copied). */
4
+ shallowCopy(): CopySlots;
5
+ /** The stored values, writable in place. */
6
+ readonly slots: Value[];
7
+ }
8
+ /**
9
+ * The value an assignment stores: arrays and UDTs deep-copied, scalars and objects as they are.
10
+ * Iterative, so any nesting depth is copied without exhausting the stack, and a container reached
11
+ * twice (or through itself) is copied once.
12
+ */
13
+ declare function copyValue(v: Value): Value;
14
+ /**
15
+ * Allocation and work limits. VBA source is untrusted: every path that allocates in proportion
16
+ * to a value the program computes checks these, and raises the error VBA raises when memory runs
17
+ * out (7 Out of memory, 14 Out of string space). Build one with {@link makeLimits}.
18
+ */
19
+ interface VbaLimits {
20
+ /** Longest string, in UTF-16 code units. */
21
+ readonly maxStringLength: number;
22
+ /** Most elements in one array (all dimensions multiplied). */
23
+ readonly maxArrayElements: number;
24
+ /** Most dimensions of an array (VBA allows 60). */
25
+ readonly maxArrayRank: number;
26
+ /** Most items in one Collection. */
27
+ readonly maxCollectionItems: number;
28
+ /** Call depth executors should allow before raising error 28 (a hint; executors enforce it). */
29
+ readonly maxCallDepth: number;
30
+ /** Most iterations a runtime search (Rate, IRR, Like backtracking) may take. */
31
+ readonly maxIterations: number;
32
+ }
33
+ /** The default limits: 16 Mi code units per string, 4 Mi array elements, 1 Mi collection items. */
34
+ declare const DEFAULT_LIMITS: VbaLimits;
35
+ /** Limits built from {@link DEFAULT_LIMITS} with some values replaced. */
36
+ declare const makeLimits: (overrides: Partial<VbaLimits>) => VbaLimits;
37
+ /** Raises error 14 when a string of `length` code units would exceed the limit. */
38
+ declare function checkStringLength(length: number, limits?: VbaLimits): void;
39
+ /**
40
+ * Raises error 7 when an array of `count` elements would exceed the limit, and error 9 when
41
+ * `rank` dimensions would.
42
+ */
43
+ declare function checkArraySize(count: number, rank: number, limits?: VbaLimits): void;
44
+ /** 0 binary (code units), 1 text (Option Compare Text rules). */
45
+ type CompareMode = 0 | 1;
46
+ /** `vbBinaryCompare` (0): strings compare by UTF-16 code units (`Option Compare Binary`). */
47
+ declare const BINARY_COMPARE: CompareMode;
48
+ /** `vbTextCompare` (1): strings compare without case, by the locale (`Option Compare Text`). */
49
+ declare const TEXT_COMPARE: CompareMode;
50
+ /**
51
+ * Resolves a library function's Compare argument. Omitted, or vbUseCompareOption (-1), takes the
52
+ * calling module's Option Compare (`moduleCompare`); 2 (vbDatabaseCompare) exists only in Access
53
+ * and raises error 5 here, as does any other number.
54
+ */
55
+ declare function compareArg(compare: Value | undefined, moduleCompare: CompareMode, env: VbaEnv): CompareMode;
56
+ type LikeElement = {
57
+ readonly kind: 'char';
58
+ readonly c: number;
59
+ } | {
60
+ readonly kind: 'any';
61
+ } | {
62
+ readonly kind: 'digit';
63
+ } | {
64
+ readonly kind: 'star';
65
+ } | LikeList;
66
+ interface LikeList {
67
+ readonly kind: 'list';
68
+ readonly negate: boolean;
69
+ /** Single code units (folded under text compare). */
70
+ readonly units: readonly number[];
71
+ /** Two-letter items a listed ß, æ, œ or þ stands for under text compare. */
72
+ readonly pairs: readonly string[];
73
+ /** Inclusive code unit ranges. */
74
+ readonly ranges: readonly (readonly [number, number])[];
75
+ /** `[]`: matches the empty string. */
76
+ readonly empty: boolean;
77
+ }
78
+ interface LikePattern {
79
+ readonly elements: readonly LikeElement[];
80
+ /** The index of the first malformed element (an unclosed or invalid list), if any. */
81
+ readonly invalidAt: number | undefined;
82
+ }
83
+ /**
84
+ * A session's cache of compiled Like patterns. Patterns in a loop are compiled once; only short
85
+ * patterns are kept, and at most `maxEntries` of them (the least recently used goes first), so a
86
+ * program that builds many distinct patterns cannot grow it without bound.
87
+ */
88
+ declare class LikePatternCache {
89
+ readonly maxEntries: number;
90
+ readonly maxPatternLength: number;
91
+ private readonly entries;
92
+ /**
93
+ * @param maxEntries how many compiled patterns are kept.
94
+ * @param maxPatternLength longer patterns are compiled every time, never kept.
95
+ */
96
+ constructor(maxEntries?: number, maxPatternLength?: number);
97
+ /** The number of compiled patterns held. */
98
+ get size(): number;
99
+ /** The compiled pattern, built by `compile` on a miss. */
100
+ lookup(pattern: string, compare: CompareMode, compile: () => LikePattern): LikePattern;
101
+ /** Drops every compiled pattern. */
102
+ clear(): void;
103
+ }
104
+ /**
105
+ * The regional settings VBA's conversions and formats read ([MS-VBAL] 5.5.1.2.4). The runtime
106
+ * never reads the machine's locale: the host passes one in the environment. Build one with
107
+ * {@link makeLocale}; {@link EN_US} is the default.
108
+ */
109
+ interface VbaLocale {
110
+ /** BCP 47 tag used for text collation (`Option Compare Text`). */
111
+ readonly tag: string;
112
+ /** Decimal symbol, e.g. "." or ",". */
113
+ readonly decimal: string;
114
+ /** Digit grouping symbol, e.g. "," or ".". */
115
+ readonly thousands: string;
116
+ /** List separator, e.g. "," or ";". */
117
+ readonly list: string;
118
+ /** The order of the numeric short date. */
119
+ readonly dateOrder: 'mdy' | 'dmy' | 'ymd';
120
+ /** Date separator, e.g. "/". */
121
+ readonly dateSep: string;
122
+ /** Time separator, e.g. ":". */
123
+ readonly timeSep: string;
124
+ /** Short date in Format codes, e.g. "m/d/yyyy". */
125
+ readonly shortDate: string;
126
+ /** Long date in Format codes, e.g. "dddd, mmmm d, yyyy". */
127
+ readonly longDate: string;
128
+ /** Long time in Format codes, e.g. "h:mm:ss AM/PM" (`ttttt`, General Date). */
129
+ readonly longTime: string;
130
+ /** Medium date in Format codes. */
131
+ readonly mediumDate: string;
132
+ /** Morning designator, e.g. "AM". */
133
+ readonly am: string;
134
+ /** Afternoon designator, e.g. "PM". */
135
+ readonly pm: string;
136
+ /** Currency symbol, e.g. "$". */
137
+ readonly currencySymbol: string;
138
+ /** Currency placement for positive amounts: 0 "$1", 1 "1$", 2 "$ 1", 3 "1 $". */
139
+ readonly currencyPositive: 0 | 1 | 2 | 3;
140
+ /** Negative currency style (Windows LOCALE_INEGCURR); 0 is "($1)". */
141
+ readonly currencyNegative: number;
142
+ /** Digits after the decimal in currency formats. */
143
+ readonly currencyDigits: number;
144
+ /** Digits after the decimal in FormatNumber/Standard. */
145
+ readonly digits: number;
146
+ /** Leading zero before the decimal symbol in fractional numbers. */
147
+ readonly leadingZero: boolean;
148
+ /** Full month names, January first. */
149
+ readonly monthNames: readonly string[];
150
+ /** Abbreviated month names, January first. */
151
+ readonly monthAbbr: readonly string[];
152
+ /** Sunday first. */
153
+ readonly dayNames: readonly string[];
154
+ /** Abbreviated day names, Sunday first. */
155
+ readonly dayAbbr: readonly string[];
156
+ /** The locale's name for `True`, accepted when a String converts to Boolean. */
157
+ readonly trueName: string;
158
+ /** The locale's name for `False`, accepted when a String converts to Boolean. */
159
+ readonly falseName: string;
160
+ }
161
+ /** United States English regional settings: the default locale. */
162
+ declare const EN_US: VbaLocale;
163
+ /** A locale built from en-US with some settings replaced. */
164
+ declare const makeLocale: (overrides: Partial<VbaLocale>) => VbaLocale;
165
+ /**
166
+ * The environment every value operation reads: regional settings, allocation limits, the clock
167
+ * and time zone, and the caches a session owns. An executor builds one per run (a `VbaSession` is
168
+ * one) and passes it to every operation as the last argument. Build one with {@link makeEnv}.
169
+ */
170
+ interface VbaEnv {
171
+ /** The regional settings conversions and formats use. */
172
+ readonly locale: VbaLocale;
173
+ /** The allocation and work limits. */
174
+ readonly limits: VbaLimits;
175
+ /** The current instant: Now, Date, Time, Timer, Randomize and the year a date string omits. */
176
+ readonly clock: () => Date;
177
+ /** Minutes east of UTC at an instant: the host's time zone, which local times are read in. */
178
+ readonly utcOffset: (instant: Date) => number;
179
+ /** Compiled Like patterns, owned by the session; without one nothing is cached. */
180
+ readonly likeCache?: LikePatternCache | undefined;
181
+ /** Receives the work big operations do (`chargeWork`); executors use it for their time limit. */
182
+ readonly meter?: WorkMeter | undefined;
183
+ }
184
+ /** Settings for {@link makeEnv}; each one omitted takes the default. */
185
+ interface EnvOptions {
186
+ /** Regional settings (default {@link EN_US}). */
187
+ readonly locale?: VbaLocale;
188
+ /** Limits (default {@link DEFAULT_LIMITS}). */
189
+ readonly limits?: VbaLimits;
190
+ /** The current instant (default the machine's clock). */
191
+ readonly clock?: () => Date;
192
+ /** Minutes east of UTC at an instant (default the machine's time zone). */
193
+ readonly utcOffset?: (instant: Date) => number;
194
+ /** A cache for compiled Like patterns (default none). */
195
+ readonly likeCache?: LikePatternCache;
196
+ readonly meter?: WorkMeter;
197
+ }
198
+ /** The machine's time zone (the default only; hosts that know better pass `utcOffset`). */
199
+ declare const machineUtcOffset: (instant: Date) => number;
200
+ /** A fixed time zone, `minutes` east of UTC (0 is UTC). */
201
+ declare const fixedUtcOffset: (minutes: number) => ((instant: Date) => number);
202
+ /**
203
+ * Where operations report work proportional to their size (characters or elements processed), so
204
+ * an executor can check its time budget after one big operation instead of only every N
205
+ * statements. Small operations report nothing.
206
+ */
207
+ interface WorkMeter {
208
+ charge(work: number): void;
209
+ }
210
+ /** Operations smaller than this report no work (the per-statement count covers them). */
211
+ declare const WORK_REPORT_MIN = 1024;
212
+ /** Reports `work` units of an operation to the environment's meter, when it is big enough. */
213
+ declare function chargeWork(env: VbaEnv, work: number): void;
214
+ /** An environment with the given settings; anything omitted takes the default. */
215
+ declare function makeEnv(options?: EnvOptions): VbaEnv;
216
+ /**
217
+ * The environment used when none is passed: en-US, the default limits, the machine's clock and
218
+ * time zone, and no Like cache.
219
+ */
220
+ declare const DEFAULT_ENV: VbaEnv;
221
+ /** Calendar fields of a local time. */
222
+ interface LocalTime {
223
+ /** The full year, e.g. 2024. */
224
+ readonly year: number;
225
+ /** The month, 1 to 12. */
226
+ readonly month: number;
227
+ /** The day of the month, 1 to 31. */
228
+ readonly day: number;
229
+ /** The hour, 0 to 23. */
230
+ readonly hour: number;
231
+ /** The minute, 0 to 59. */
232
+ readonly minute: number;
233
+ /** The second, 0 to 59. */
234
+ readonly second: number;
235
+ /** The millisecond, 0 to 999. */
236
+ readonly millisecond: number;
237
+ }
238
+ /** An instant as local calendar fields in a time zone `offset` minutes east of UTC. */
239
+ declare function localFields(instant: Date, offset: number): LocalTime;
240
+ /** The environment's current local time. */
241
+ declare function localNow(env: VbaEnv): LocalTime;
242
+ /** The current local year: what a date string without a year means. */
243
+ declare const currentYear: (env: VbaEnv) => number;
244
+ /** The bounds of one array dimension, both inclusive (`Dim a(lo To hi)`). */
245
+ interface Bound {
246
+ /** The lower bound (`LBound`). */
247
+ readonly lo: number;
248
+ /** The upper bound (`UBound`); `lo - 1` for an empty dimension. */
249
+ readonly hi: number;
250
+ }
251
+ /** The value a fresh element of a declared type holds. */
252
+ declare function defaultFor(vt: number): Value;
253
+ /** Options for a new {@link VbaArray}. */
254
+ interface ArrayOptions {
255
+ /** Declared with bounds (`Dim a(3)`): cannot be ReDimmed or Erased to nothing. */
256
+ readonly fixed?: boolean;
257
+ /** Builds a fresh element (UDT element types). Defaults to `defaultFor(elemVt)`. */
258
+ readonly init?: () => Value;
259
+ /** Regional settings for element coercion and the size limits. */
260
+ readonly env?: VbaEnv;
261
+ /**
262
+ * Count the references the elements hold (lifetime.ts): storing retains the new object and
263
+ * releases the old one, Erase and ReDim release what they drop, `releaseAll` releases every
264
+ * element when the variable holding the array goes. Without it, executors escape stored objects.
265
+ */
266
+ readonly counting?: boolean;
267
+ }
268
+ /**
269
+ * A VBA array ([MS-VBAL] 2.1.1, 5.4.3.3): any rank, any lower bounds, fixed or resizable, with
270
+ * typed or Variant elements. Elements are stored column-major (the first index varies fastest),
271
+ * the order `For Each` visits them in. Indexing out of range or with the wrong rank raises
272
+ * error 9; resizing a fixed or locked array raises error 10. The array is a mutable container:
273
+ * stores copy it (see {@link copyValue}).
274
+ */
275
+ declare class VbaArray implements CopySlots {
276
+ readonly elemVt: number;
277
+ /** The bounds of each dimension; empty for an unallocated dynamic array. */
278
+ bounds: Bound[];
279
+ /** The elements in storage order (column-major). */
280
+ data: Value[];
281
+ /** Raised while `For Each` walks the array or a ByRef element is borrowed (error 10). */
282
+ locked: number;
283
+ /** True for an array declared with bounds, which ReDim cannot resize. */
284
+ readonly fixed: boolean;
285
+ readonly counting: boolean;
286
+ private readonly init;
287
+ private readonly env;
288
+ /** @param elemVt the element's declared type: a `VT.*` scalar, `VT.Variant`, `VT.Object` or `VT.UserDefinedType`. */
289
+ constructor(elemVt: number, bounds?: readonly Bound[], options?: ArrayOptions);
290
+ /** The number of dimensions; 0 when unallocated. */
291
+ get rank(): number;
292
+ /** The total number of elements. */
293
+ get count(): number;
294
+ private allocate;
295
+ /** The storage offset of an index tuple; error 9 when out of range or of the wrong rank. */
296
+ offset(indices: readonly number[]): number;
297
+ /** Reads an element; error 9 when out of range or of the wrong rank. */
298
+ get(indices: readonly number[]): Value;
299
+ /**
300
+ * Stores an element, Let-coerced to the element type (objects as-is in Object arrays; arrays
301
+ * and UDTs copied, see copy.ts).
302
+ */
303
+ set(indices: readonly number[], value: Value): void;
304
+ private store;
305
+ /** Releases every element's reference (a counting array whose variable goes away). */
306
+ releaseAll(): void;
307
+ /** The storage offset of a one-dimensional index. */
308
+ private offset1;
309
+ /** `get([index])` for a one-dimensional array, without the index tuple. */
310
+ get1(index: number): Value;
311
+ /** `set([index], value)` for a one-dimensional array, without the index tuple. */
312
+ set1(index: number, value: Value): void;
313
+ private coerce;
314
+ /** `LBound(a, dim)`: error 9 for an unallocated array or a bad dimension. */
315
+ lbound(dim?: number): number;
316
+ /** `UBound(a, dim)`: error 9 for an unallocated array or a bad dimension. */
317
+ ubound(dim?: number): number;
318
+ /**
319
+ * `ReDim [Preserve]` ([MS-VBAL] 5.4.3.3). Preserve keeps the elements in storage order and may
320
+ * change only the last dimension: its upper bound, and also its lower bound when the array is
321
+ * held in a Variant (`inVariant`; Office allows `v = Array(1, 2, 3): ReDim Preserve v(-1 To 1)`
322
+ * but raises 9 for a typed array, `Variant()` included).
323
+ */
324
+ redim(bounds: readonly Bound[], preserve?: boolean, inVariant?: boolean): void;
325
+ /** `Erase`: a fixed array is reset to default values, a resizable one loses its storage. */
326
+ erase(): void;
327
+ /**
328
+ * A deep copy (UDT and array elements are copied too). The copy keeps the fixed size of a fixed
329
+ * array unless `resizable` (what assigning to a resizable array variable makes).
330
+ */
331
+ copy(resizable?: boolean): VbaArray;
332
+ /** A copy sharing the element values (copy.ts copies the nested ones). */
333
+ shallowCopy(fixed?: boolean): VbaArray;
334
+ get slots(): Value[];
335
+ /** The elements in `For Each` order. */
336
+ values(): readonly Value[];
337
+ }
338
+ /** Builds a one-dimensional Variant array from values (the `Array` function, ParamArray). */
339
+ declare function arrayOf(values: readonly Value[], lo?: number, env?: VbaEnv): VbaArray;
340
+ /**
341
+ * Let-assignment of a whole array to a resizable array variable ([MS-VBAL] 5.5.1.2.6-7): a copy
342
+ * when the element types match, a String's bytes for a Byte array, else error 13.
343
+ */
344
+ declare function assignArray(elemVt: number, v: Value, env?: VbaEnv): VbaArray;
345
+ /** One field of a user-defined type, as a {@link UdtType} declares it. */
346
+ interface UdtField {
347
+ /** The field name; lookups ignore case. */
348
+ readonly name: string;
349
+ /** A `VT.*` scalar, `VT.Variant`, `VT.Object`, `VT.UserDefinedType` or `VT.Array`. */
350
+ readonly vt: number;
351
+ /** `String * n`. */
352
+ readonly fixedLength?: number;
353
+ /** The nested type of a UDT field. */
354
+ readonly type?: UdtType;
355
+ /** Builds the initial array of an array field (`a(1 To 3) As Long`). */
356
+ readonly array?: () => VbaArray;
357
+ }
358
+ /**
359
+ * A user-defined type ([MS-VBAL] 5.2.3.3), built once per `Type` declaration. Its values are
360
+ * {@link Udt} records made by `create`. See also {@link defineUdt}.
361
+ */
362
+ declare class UdtType {
363
+ /** The type name. */
364
+ readonly name: string;
365
+ /** The fields, in declaration order. */
366
+ readonly fields: readonly UdtField[];
367
+ readonly env: VbaEnv;
368
+ private readonly index;
369
+ /** @param env the regional settings field assignments coerce with. */
370
+ constructor(
371
+ /** The type name. */
372
+ name: string,
373
+ /** The fields, in declaration order. */
374
+ fields: readonly UdtField[], env?: VbaEnv);
375
+ /** The position of a field (case-insensitive); error 438 when there is none. */
376
+ fieldIndex(name: string): number;
377
+ /** A new value with every field at its default. */
378
+ create(): Udt;
379
+ }
380
+ /**
381
+ * A value of a user-defined type: a mutable record with value semantics. Stores copy it (see
382
+ * {@link copyValue}); fields are coerced to their declared types.
383
+ */
384
+ declare class Udt implements CopySlots {
385
+ /** The record's type. */
386
+ readonly type: UdtType;
387
+ /** The field values, in the order of `type.fields`. */
388
+ readonly values: Value[];
389
+ constructor(
390
+ /** The record's type. */
391
+ type: UdtType,
392
+ /** The field values, in the order of `type.fields`. */
393
+ values: Value[]);
394
+ /** Reads a field by name (any case); error 438 when the type has no such field. */
395
+ get(field: string): Value;
396
+ /** Stores a field, coerced to its declared type (copying arrays and UDTs). */
397
+ set(field: string, value: Value): void;
398
+ /** A deep copy (array and UDT fields are copied too). */
399
+ copy(): Udt;
400
+ /** A copy sharing the field values (copy.ts copies the nested ones). */
401
+ shallowCopy(): Udt;
402
+ get slots(): Value[];
403
+ }
404
+ /** Declares a UDT: `defineUdt('Point', [{ name: 'X', vt: VT.Long }, ...])`. */
405
+ declare const defineUdt: (name: string, fields: readonly UdtField[], env?: VbaEnv) => UdtType;
406
+ /**
407
+ * A ByRef reference ([MS-VBAL] 5.3.1.11): what a ByRef parameter points at. The callee reads and
408
+ * writes through it; every store copies an array or UDT value.
409
+ */
410
+ interface Ref {
411
+ /** Reads the current value. */
412
+ get(): Value;
413
+ /** Stores a value: Let-coerced to the cell's declared type, if it has one. */
414
+ set(value: Value): void;
415
+ }
416
+ /**
417
+ * A variable cell. With `vt` (a `VT.*` scalar type) stores are Let-coerced to it; without, an
418
+ * array or UDT value is copied.
419
+ */
420
+ declare class Cell implements Ref {
421
+ /** The declared scalar type (a `VT.*` number) stores coerce to; undefined for Variant (named so a Cell never looks like a Value). */
422
+ readonly declaredVt?: number | undefined;
423
+ private readonly env;
424
+ /** The stored value. Assigning it directly skips the coercion and copy `set` does. */
425
+ value: Value;
426
+ constructor(value?: Value,
427
+ /** The declared scalar type (a `VT.*` number) stores coerce to; undefined for Variant (named so a Cell never looks like a Value). */
428
+ declaredVt?: number | undefined, env?: VbaEnv);
429
+ private store;
430
+ /** Reads the current value. */
431
+ get(): Value;
432
+ set(value: Value): void;
433
+ }
434
+ /** A new variable cell, optionally of a declared scalar type. */
435
+ declare const cell: (value?: Value, vt?: number, env?: VbaEnv) => Cell;
436
+ /** A temporary for an expression or property passed ByRef: writes are kept but go nowhere else. */
437
+ declare const tempRef: (value: Value) => Cell;
438
+ /** An array element. Indices are checked on every access (the array may be ReDimmed). */
439
+ declare function elemRef(array: VbaArray, indices: readonly number[]): Ref;
440
+ /** A field of a user-defined type value. */
441
+ declare function fieldRef(udt: Udt, field: string): Ref;
442
+ /**
443
+ * A cell over a getter and setter the executor supplies (a module variable, a closure slot). The
444
+ * setter receives a copy of an array or UDT value.
445
+ */
446
+ declare const refOf: (get: () => Value, set: (value: Value) => void) => Ref;
447
+ /** How many default members deep a value is read before error 443. */
448
+ declare const MAX_DEFAULT_DEPTH = 16;
449
+ /**
450
+ * The simple data value of a value: an object's default member (Nothing raises 91). Synchronous:
451
+ * a host object marked `async` is refused before it is called, and a member that answers with a
452
+ * Promise anyway is an executor bug, reported as a `VbaAbort` (never trapped by On Error) after
453
+ * the Promise's rejection is handled.
454
+ */
455
+ declare function scalar(v: Value): Value;
456
+ /**
457
+ * Resolves a value to its simple data value, awaiting asynchronous default members. Executors call
458
+ * it on object operands before a synchronous operator when their host may be asynchronous.
459
+ */
460
+ declare function resolveDefault(v: Value): Promise<Value>;
461
+ /**
462
+ * The simple data value, synchronous while every default member answers synchronously: a Promise
463
+ * appears only when a host's `get('')` returns one (compiled code and the interpreter's fast path).
464
+ */
465
+ declare function resolveDefaultMaybe(v: Value, depth?: number): MaybePromise<Value>;
466
+ /**
467
+ * The value an information function (IsEmpty, VarType, IsNumeric, ...) inspects: an object with a
468
+ * default member that needs no arguments reads as that member's value; an object without one (a
469
+ * Collection, Nothing) stays an object.
470
+ */
471
+ declare function inspected(v: Value): Value;
472
+ /** A result a host may give synchronously or as a Promise. */
473
+ type MaybePromise<T> = T | Promise<T>;
474
+ /** Named arguments of a call (`Find(What:="x")`), by lower-case name. */
475
+ type NamedArgs = ReadonlyMap<string, Value>;
476
+ /** Receives the events a host object raises (`WithEvents`, document modules). */
477
+ interface EventSink {
478
+ /**
479
+ * Runs the user's handler for `event`, if any. `args` are reference cells so a handler can set
480
+ * `Cancel = True`; the host reads them back after the returned value settles.
481
+ */
482
+ fire(source: VbaObject, event: string, args: readonly Ref[]): MaybePromise<void>;
483
+ }
484
+ /**
485
+ * The host object protocol: the one interface every object model (and the runtime's own
486
+ * Collection) implements and both executors call. Member names are case-insensitive. Any member
487
+ * may answer with a Promise, which executors await; the runtime's synchronous paths refuse an
488
+ * object marked `async`. Build one with {@link hostClass}, or implement it directly.
489
+ */
490
+ interface VbaObject {
491
+ /**
492
+ * True when members may answer with a Promise. The runtime's synchronous paths refuse such an
493
+ * object before calling it, so a member's side effects never run twice or half-way.
494
+ */
495
+ readonly async?: boolean;
496
+ /** `TypeName(obj)`: the class name, e.g. "Range", "Collection". */
497
+ typeName(): string;
498
+ /**
499
+ * Property Get or a Function call that returns a value: `obj.Name`, `obj.Item(1)`,
500
+ * `obj(1)`. `name` is "" for the default member. Unknown members raise error 438.
501
+ */
502
+ get(name: string, args: readonly Value[], named?: NamedArgs): MaybePromise<Value>;
503
+ /** Property Let: `obj.Name(args) = value`. */
504
+ let(name: string, args: readonly Value[], value: Value): MaybePromise<void>;
505
+ /** Property Set: `Set obj.Name(args) = object`. */
506
+ set(name: string, args: readonly Value[], value: VObj): MaybePromise<void>;
507
+ /** A Sub call, or a Function whose result is discarded. Returns the result if any. */
508
+ call(name: string, args: readonly Value[], named?: NamedArgs): MaybePromise<Value>;
509
+ /** `For Each x In obj`; absent means error 438. */
510
+ enumerate?(): Iterable<Value> | AsyncIterable<Value>;
511
+ /** Subscribes to the object's events; returns the function that unsubscribes. */
512
+ connect?(sink: EventSink): () => void;
513
+ /**
514
+ * The identity `Is` compares. Defaults to the object itself; a host that hands out several
515
+ * wrappers for one underlying object returns that object here.
516
+ */
517
+ identity?(): unknown;
518
+ }
519
+ /**
520
+ * Error 438 for a member an object does not have, with Office's description (which does not name
521
+ * the member). `member` is accepted for callers that have it.
522
+ */
523
+ declare function noMember(_member?: string): never;
524
+ /** The default member's value. Hosts without one raise 438 from `get('')`. */
525
+ declare const defaultValue: (o: VbaObject) => MaybePromise<Value>;
526
+ /** `a Is b` ([MS-VBAL] 5.6.9.7): both must be objects or Nothing, else error 424. */
527
+ declare function sameObject(a: Value, b: Value): boolean;
528
+ /** Lists the items of `For Each` over an object: error 438 when it does not enumerate. */
529
+ declare function enumerateObject(o: VbaObject): Iterable<Value> | AsyncIterable<Value>;
530
+ /** Fan-out of a host object's events to every connected sink (hosts embed one). */
531
+ declare class EventHub {
532
+ private readonly sinks;
533
+ /** Adds a sink; returns the function that removes it. */
534
+ connect(sink: EventSink): () => void;
535
+ /** Fires an event at every sink in turn, awaiting asynchronous handlers. */
536
+ raise(source: VbaObject, event: string, args: readonly Ref[]): Promise<void>;
537
+ /** The number of connected sinks. */
538
+ get size(): number;
539
+ }
540
+ /** The `Is` operator as a Boolean value. */
541
+ declare const is: (a: Value, b: Value) => Value;
542
+ /** `VbVarType` numbers ([MS-VBAL] 6.1.1.16). */
543
+ declare const VT: {
544
+ /** `vbEmpty`: an uninitialised Variant. */
545
+ readonly Empty: 0;
546
+ /** `vbNull`: no valid data. */
547
+ readonly Null: 1;
548
+ /** `vbInteger`. */
549
+ readonly Integer: 2;
550
+ /** `vbLong`. */
551
+ readonly Long: 3;
552
+ /** `vbSingle`. */
553
+ readonly Single: 4;
554
+ /** `vbDouble`. */
555
+ readonly Double: 5;
556
+ /** `vbCurrency`. */
557
+ readonly Currency: 6;
558
+ /** `vbDate`. */
559
+ readonly Date: 7;
560
+ /** `vbString`. */
561
+ readonly String: 8;
562
+ /** `vbObject`: an object reference, `Nothing` included. */
563
+ readonly Object: 9;
564
+ /** `vbError`: an Error value (`CVErr`). */
565
+ readonly Error: 10;
566
+ /** `vbBoolean`. */
567
+ readonly Boolean: 11;
568
+ /** `vbVariant`: the declared type Variant (8204 is a Variant array); no value has it. */
569
+ readonly Variant: 12;
570
+ /** `vbDataObject`: not produced by this runtime. */
571
+ readonly DataObject: 13;
572
+ /** `vbDecimal`. */
573
+ readonly Decimal: 14;
574
+ /** `vbByte`. */
575
+ readonly Byte: 17;
576
+ /** `vbLongLong`. */
577
+ readonly LongLong: 20;
578
+ /** `vbUserDefinedType`. */
579
+ readonly UserDefinedType: 36;
580
+ /** `vbArray`: added to the element type of an array. */
581
+ readonly Array: 8192;
582
+ };
583
+ /** The Empty value (`vt` 0): an uninitialised Variant. */
584
+ type VEmpty = {
585
+ readonly vt: 0;
586
+ };
587
+ /** The Null value (`vt` 1): a Variant holding no valid data. */
588
+ type VNull = {
589
+ readonly vt: 1;
590
+ };
591
+ /**
592
+ * An Integer (`vt` 2): a 16-bit signed whole number in `v`. Integer, Long, Single, Double, Date
593
+ * (OLE serial) and Byte hold a JS number.
594
+ */
595
+ type VInt = {
596
+ readonly vt: 2;
597
+ readonly v: number;
598
+ };
599
+ /** A Long (`vt` 3): a 32-bit signed whole number in `v`. */
600
+ type VLng = {
601
+ readonly vt: 3;
602
+ readonly v: number;
603
+ };
604
+ /** A Single (`vt` 4): a 32-bit float in `v`, already rounded with `Math.fround`. */
605
+ type VSng = {
606
+ readonly vt: 4;
607
+ readonly v: number;
608
+ };
609
+ /** A Double (`vt` 5): a 64-bit float in `v`. */
610
+ type VDbl = {
611
+ readonly vt: 5;
612
+ readonly v: number;
613
+ };
614
+ /** A Currency (`vt` 6): an exact 64-bit integer count of ten-thousandths in `v`. */
615
+ type VCur = {
616
+ readonly vt: 6;
617
+ readonly v: bigint;
618
+ };
619
+ /**
620
+ * A Date (`vt` 7): an OLE date serial in `v` (whole days since 30 December 1899, with the time
621
+ * of day as the fraction).
622
+ */
623
+ type VDate = {
624
+ readonly vt: 7;
625
+ readonly v: number;
626
+ };
627
+ /** A String (`vt` 8): the text in `v`. */
628
+ type VStr = {
629
+ readonly vt: 8;
630
+ readonly v: string;
631
+ };
632
+ /** An object reference (`vt` 9) in `v`; `null` is `Nothing`. */
633
+ type VObj = {
634
+ readonly vt: 9;
635
+ readonly v: VbaObject | null;
636
+ };
637
+ /** An Error value (`vt` 10, `CVErr`): a standard error code in `v`, or an HRESULT for `Missing`. */
638
+ type VErr = {
639
+ readonly vt: 10;
640
+ readonly v: number;
641
+ };
642
+ /** A Boolean (`vt` 11) in `v`. */
643
+ type VBool = {
644
+ readonly vt: 11;
645
+ readonly v: boolean;
646
+ };
647
+ /**
648
+ * A Decimal (`vt` 14): the value is `v / 10^s`, with the absolute value of `v` less than 2^96 and
649
+ * `s` (the scale) from 0 to 28.
650
+ */
651
+ type VDec = {
652
+ readonly vt: 14;
653
+ readonly v: bigint;
654
+ readonly s: number;
655
+ };
656
+ /** A Byte (`vt` 17): a whole number from 0 to 255 in `v`. */
657
+ type VByte = {
658
+ readonly vt: 17;
659
+ readonly v: number;
660
+ };
661
+ /** A LongLong (`vt` 20): a 64-bit signed integer in `v`. */
662
+ type VLLng = {
663
+ readonly vt: 20;
664
+ readonly v: bigint;
665
+ };
666
+ /** A user-defined type value (`vt` 36): the mutable record in `v`, copied on assignment. */
667
+ type VUdt = {
668
+ readonly vt: 36;
669
+ readonly v: Udt;
670
+ };
671
+ /**
672
+ * An array (`vt` 8192, the `vbArray` flag): the mutable array in `v`, copied on assignment. The
673
+ * element type lives on the array, not in `vt`.
674
+ */
675
+ type VArr = {
676
+ readonly vt: 8192;
677
+ readonly v: VbaArray;
678
+ };
679
+ /**
680
+ * Any VBA value: a Variant. Each member is a plain, immutable object tagged by `vt`, its `VarType`
681
+ * number (see {@link VT}), with the payload in `v`. Build literals with the `v...` constructors
682
+ * and the {@link EMPTY}, {@link NULL}, {@link NOTHING}, {@link TRUE}, {@link FALSE} and
683
+ * {@link MISSING} constants.
684
+ */
685
+ type Value = VEmpty | VNull | VInt | VLng | VSng | VDbl | VCur | VDate | VStr | VObj | VErr | VBool | VDec | VByte | VLLng | VUdt | VArr;
686
+ /** The numeric value types. */
687
+ type VNum = VInt | VLng | VSng | VDbl | VCur | VDate | VDec | VByte | VLLng;
688
+ /** The shared Empty value. */
689
+ declare const EMPTY: VEmpty;
690
+ /** The shared Null value. */
691
+ declare const NULL: VNull;
692
+ /** The object reference `Nothing`. */
693
+ declare const NOTHING: VObj;
694
+ /** The Boolean `True` (VBA's `True` is -1 when converted to a number). */
695
+ declare const TRUE: VBool;
696
+ /** The Boolean `False`. */
697
+ declare const FALSE: VBool;
698
+ /** The zero-length String `""`. */
699
+ declare const EMPTY_STR: VStr;
700
+ /** DISP_E_PARAMNOTFOUND: the value of an omitted optional Variant parameter (`IsMissing`). */
701
+ declare const MISSING_CODE = -2147352572;
702
+ /** The Error value an omitted optional Variant parameter holds; `IsMissing` is true for it. */
703
+ declare const MISSING: VErr;
704
+ /** An Integer value. */
705
+ declare const vInt: (v: number) => VInt;
706
+ /** A Long value. */
707
+ declare const vLng: (v: number) => VLng;
708
+ /** A Single value; the number is rounded to single precision. */
709
+ declare const vSng: (v: number) => VSng;
710
+ /** A Double value. */
711
+ declare const vDbl: (v: number) => VDbl;
712
+ /** A Currency from its scaled count of ten-thousandths. */
713
+ declare const vCur: (v: bigint) => VCur;
714
+ /** A Date value from an OLE date serial. */
715
+ declare const vDate: (v: number) => VDate;
716
+ /** A String value. */
717
+ declare const vStr: (v: string) => VStr;
718
+ /** An object reference; `null` gives the shared {@link NOTHING}. */
719
+ declare const vObj: (v: VbaObject | null) => VObj;
720
+ /** An Error value (as `CVErr` returns) with the given code. */
721
+ declare const vErr: (v: number) => VErr;
722
+ /** A Boolean value: the shared {@link TRUE} or {@link FALSE}. */
723
+ declare const vBool: (v: boolean) => VBool;
724
+ /** A Decimal value `v / 10^s` (scale `s`, default 0). */
725
+ declare const vDec: (v: bigint, s?: number) => VDec;
726
+ /** A Byte value. */
727
+ declare const vByte: (v: number) => VByte;
728
+ /** A LongLong value. */
729
+ declare const vLLng: (v: bigint) => VLLng;
730
+ /** An array value wrapping a {@link VbaArray}. The array is not copied. */
731
+ declare const vArr: (v: VbaArray) => VArr;
732
+ /** A user-defined type value wrapping a {@link Udt}. The record is not copied. */
733
+ declare const vUdt: (v: Udt) => VUdt;
734
+ /** True for a runtime `Value` (an object with a known `vt`). */
735
+ declare const isValue: (x: unknown) => x is Value;
736
+ /**
737
+ * Converts a plain JS value (number, string, boolean, bigint, Date, null, undefined) to a Variant;
738
+ * a `Value` passes through. Anything else raises error 458 (a type VBA cannot hold). A Date reads
739
+ * as local time in the given time zone (minutes east of UTC; default the machine's).
740
+ */
741
+ declare function fromJs(value: unknown, utcOffset?: (instant: Date) => number): Value;
742
+ /**
743
+ * The local calendar time of a JS Date as an OLE serial, in a time zone `offset` minutes east of
744
+ * UTC (default: the machine's). Milliseconds are dropped, as the VBA clock functions do.
745
+ */
746
+ declare function jsDateToSerial(d: Date, offset?: number): number;
747
+ /** True when an optional argument was supplied (not `undefined` and not `Missing`). */
748
+ declare const given: (v: Value | undefined) => v is Value;
749
+ /** The message for a user or application error number with no standard message. */
750
+ declare const APP_DEFINED = "Application-defined or object-defined error";
751
+ /** The standard message for a VBA error number, or the application-defined text. */
752
+ declare function errorMessage(n: number): string;
753
+ /** True when `n` has a standard VBA message (it is one of the trappable runtime errors). */
754
+ declare const isStandardError: (n: number) => boolean;
755
+ /** A trappable VBA runtime error. `On Error` handlers catch these. */
756
+ declare class VbaRuntimeError extends Error {
757
+ /** Always `'VbaRuntimeError'`. */
758
+ readonly name = "VbaRuntimeError";
759
+ /** The VBA error number (`Err.Number`); negative for an HRESULT. */
760
+ readonly number: number;
761
+ /** `Err.Description`: the given text, or the standard message for the number. */
762
+ readonly description: string;
763
+ /** `Err.Source`; empty when not given. */
764
+ readonly source: string;
765
+ /** `Err.HelpFile`; empty when not given. */
766
+ readonly helpFile: string;
767
+ /** `Err.HelpContext`; 0 when not given. */
768
+ readonly helpContext: number;
769
+ constructor(number: number, description?: string, source?: string, helpFile?: string, helpContext?: number);
770
+ }
771
+ /**
772
+ * An error `On Error` must never trap: the host stopped the run (time, step or memory limit, user
773
+ * cancel, `End`). Executors let it propagate to the top and report it.
774
+ */
775
+ declare class VbaAbort extends Error {
776
+ /**
777
+ * `end` the End statement, `limit` a resource limit, `cancel` the host cancelled, `internal`
778
+ * an executor contract was broken (an asynchronous host reached a synchronous path).
779
+ */
780
+ readonly reason: 'end' | 'limit' | 'cancel' | 'internal';
781
+ /** Always `'VbaAbort'`. */
782
+ readonly name = "VbaAbort";
783
+ constructor(
784
+ /**
785
+ * `end` the End statement, `limit` a resource limit, `cancel` the host cancelled, `internal`
786
+ * an executor contract was broken (an asynchronous host reached a synchronous path).
787
+ */
788
+ reason: 'end' | 'limit' | 'cancel' | 'internal', message?: string);
789
+ }
790
+ /** Builds a runtime error with the standard message. Executors `throw vbaError(n)`. */
791
+ declare const vbaError: (n: number, description?: string) => VbaRuntimeError;
792
+ /** Raises a runtime error. Typed `never` so it can end an expression. */
793
+ declare function raise(n: number, description?: string): never;
794
+ /**
795
+ * Error 445 for a feature this environment does not provide (`Shell`, `Declare`, external COM
796
+ * servers). The description names the feature, so the gap is reported honestly.
797
+ */
798
+ declare function notSupported(feature: string): never;
799
+ /**
800
+ * Converts anything thrown inside user code to the error `On Error` sees. A JS stack overflow
801
+ * becomes error 28; any other non-VBA error becomes error 51 (Internal error) with its message.
802
+ * `VbaAbort` is returned unchanged; callers must rethrow it (`isTrappable` is false).
803
+ */
804
+ declare function toVbaError(e: unknown): VbaRuntimeError | VbaAbort;
805
+ /** False for host aborts, which `On Error` must not catch. */
806
+ declare const isTrappable: (e: unknown) => boolean;
807
+ /**
808
+ * VBA's `Err` object ([MS-VBAL] 6.1.3.2): one per session, read and written by user code and
809
+ * updated by the executor when an `On Error` handler traps an error. `Raise` follows Office: the
810
+ * number is read as a Long and must be 1 to 65535 or negative (an HRESULT), otherwise error 5 is
811
+ * recorded instead; an omitted Source, Description or HelpFile keeps the one Err already holds
812
+ * until `Clear`.
813
+ */
814
+ declare class ErrObject {
815
+ readonly projectName: string;
816
+ /** `Err.Number`: setting it changes nothing else. */
817
+ number: number;
818
+ /** `Err.HelpContext`. */
819
+ helpContext: number;
820
+ /** Win32 errors from `Declare`d DLL calls; always 0 here (DLL calls are not supported). */
821
+ lastDllError: number;
822
+ private desc;
823
+ private src;
824
+ private file;
825
+ /** The error the last Err.Raise threw, so trapping it does not record it twice. */
826
+ private raised;
827
+ /** @param projectName the default `Source` of errors user code raises. */
828
+ constructor(projectName?: string);
829
+ /** `Err.Description`; empty until set by user code, a trapped error or `Raise`. */
830
+ get description(): string;
831
+ /** Sets `Err.Description`. */
832
+ set description(text: string);
833
+ /** `Err.Source`; empty until set by user code, a trapped error or `Raise`. */
834
+ get source(): string;
835
+ /** Sets `Err.Source`. */
836
+ set source(text: string);
837
+ /** `Err.HelpFile`; empty until set by user code, a trapped error or `Raise`. */
838
+ get helpFile(): string;
839
+ /** Sets `Err.HelpFile`. */
840
+ set helpFile(text: string);
841
+ /**
842
+ * The current state, to put back with the returned function (an executor that swallows an
843
+ * error, such as one leaving Class_Terminate, leaves Err as the interrupted code had it).
844
+ */
845
+ save(): () => void;
846
+ /** `Err.Clear`: also what `Resume`, `On Error`, `Exit Sub/Function/Property` do. */
847
+ clear(): void;
848
+ /**
849
+ * `Err.Raise number, [source], [description], [helpfile], [helpcontext]`. Omitted arguments are
850
+ * `undefined` or `MISSING`. Always throws the error it records.
851
+ */
852
+ raise(number: Value, source?: Value, description?: Value, helpFile?: Value, helpContext?: Value, env?: VbaEnv): never;
853
+ private build;
854
+ /**
855
+ * Records an error an `On Error` handler trapped and returns it. A `VbaAbort` (or anything
856
+ * else `On Error` must not catch) is rethrown.
857
+ */
858
+ capture(e: unknown): VbaRuntimeError;
859
+ /** The error to rethrow from a handler that does not resume (re-raises the current Err). */
860
+ current(): VbaRuntimeError;
861
+ private fill;
862
+ }
863
+ /**
864
+ * The `On Error` state of one procedure activation, kept by the executor in its frame. The runtime
865
+ * only defines the shape and the transitions; the executor decides where to jump.
866
+ *
867
+ * - `mode` is `'goto0'` (errors propagate), `'next'` (`On Error Resume Next`) or `'label'`.
868
+ * - `handling` is true while a handler runs: an error raised then propagates to the caller
869
+ * (VBA does not re-enter an active handler), and `Resume` ends it.
870
+ */
871
+ interface OnErrorState {
872
+ /** What the next error does: propagate, resume next, or jump to `label`. */
873
+ mode: 'goto0' | 'next' | 'label';
874
+ /** The handler label when `mode` is `'label'`, otherwise undefined. */
875
+ label: string | undefined;
876
+ /** True while an error handler runs, until `Resume` or `On Error GoTo -1` ends it. */
877
+ handling: boolean;
878
+ }
879
+ /** The initial {@link OnErrorState} of a procedure activation: `On Error GoTo 0`, not handling. */
880
+ declare const onErrorState: () => OnErrorState;
881
+ /**
882
+ * What an executor does with an error thrown at a statement, given the frame's state:
883
+ * `'next'` continue with the next statement, `'handler'` jump to the label, `'propagate'` rethrow.
884
+ * Records the error in `err` when it is trapped.
885
+ */
886
+ declare function onError(state: OnErrorState, err: ErrObject, e: unknown): 'next' | 'handler' | 'propagate';
887
+ /**
888
+ * An `On Error` statement: `goto0` (On Error GoTo 0), `next` (On Error Resume Next), `label`
889
+ * (On Error GoTo label) or `reset` (On Error GoTo -1, which ends the active handler so a new
890
+ * On Error takes effect inside it). Every form clears Err. Inside an active handler only `reset`
891
+ * and `goto0` change what happens to the next error: until the handler ends, an error propagates
892
+ * to the caller whatever the mode says, as observed in Office.
893
+ */
894
+ declare function setOnError(state: OnErrorState, err: ErrObject, target: 'goto0' | 'next' | 'label' | 'reset', label?: string): void;
895
+ /** `Resume`, `Resume Next` or `Resume label`: leaves the handler and clears Err. */
896
+ declare function resume(state: OnErrorState, err: ErrObject): void;
897
+ /** The dialogs `MsgBox` and `InputBox` delegate to. Either may answer asynchronously. */
898
+ interface VbaUi {
899
+ /** Returns the `VbMsgBoxResult` of the button pressed (1 OK, 2 Cancel, 6 Yes, 7 No, ...). */
900
+ msgBox(prompt: string, buttons: number, title: string): MaybePromise<number>;
901
+ /** Returns the text entered, or `null` for Cancel (InputBox then returns ""). */
902
+ inputBox(prompt: string, title: string, defaultText: string): MaybePromise<string | null>;
903
+ }
904
+ /** Where `Debug.Print` writes; `Debug.Assert False` calls `assertFailed`. */
905
+ interface DebugSink {
906
+ /** Receives the text of one `Debug.Print` line. */
907
+ print(text: string): void;
908
+ /** Called when `Debug.Assert` fails; optional. */
909
+ assertFailed?(): void;
910
+ }
911
+ /** The state of VBA's Rnd generator: a 24-bit seed. */
912
+ interface RndState {
913
+ /** The current 24-bit seed. */
914
+ seed: number;
915
+ /** The last value Rnd returned (`Rnd(0)` repeats it). */
916
+ last: number;
917
+ }
918
+ /** VBA's documented initial seed: an unseeded program gets the same sequence every run. */
919
+ declare const RND_INITIAL_SEED = 327680;
920
+ /**
921
+ * The state one running VBA program shares: its environment (a session is a {@link VbaEnv}), the
922
+ * Err object, the Rnd generator, the host UI, the Debug sink and the environment variables.
923
+ * Executors create one per run with {@link createSession}. Functions that read or change session
924
+ * state take the session as their first argument.
925
+ */
926
+ interface VbaSession extends VbaEnv {
927
+ /** The program's `Err` object. */
928
+ readonly err: ErrObject;
929
+ /** The state of the Rnd generator. */
930
+ readonly rnd: RndState;
931
+ /** The host's MsgBox and InputBox dialogs; undefined when the host has none. */
932
+ readonly ui: VbaUi | undefined;
933
+ /** Where `Debug.Print` writes. */
934
+ readonly debug: DebugSink;
935
+ /**
936
+ * `Environ(name)`; undefined reads as "". The default host exposes no variables. Anything but a
937
+ * string is ignored, so a host may back it with a plain object.
938
+ */
939
+ readonly environ: (name: string) => string | undefined;
940
+ /** The project name, the default `Err.Source`. */
941
+ readonly projectName: string;
942
+ }
943
+ /** Settings for {@link createSession}; each one omitted takes the default. */
944
+ interface SessionOptions {
945
+ /** Regional settings (default {@link EN_US}). */
946
+ readonly locale?: VbaLocale;
947
+ /** Limits (default {@link DEFAULT_LIMITS}). */
948
+ readonly limits?: VbaLimits;
949
+ /** The MsgBox and InputBox dialogs (default none). */
950
+ readonly ui?: VbaUi;
951
+ /** Where `Debug.Print` writes (default nowhere). */
952
+ readonly debug?: DebugSink;
953
+ /** Looks up `Environ` variables (default none are defined). */
954
+ readonly environ?: (name: string) => string | undefined;
955
+ /** The current instant (default the machine's clock). */
956
+ readonly clock?: () => Date;
957
+ /** Minutes east of UTC at an instant (default: the machine's time zone). */
958
+ readonly utcOffset?: (instant: Date) => number;
959
+ /** The project name, the default `Err.Source` (default `"VBAProject"`). */
960
+ readonly projectName?: string;
961
+ /** Receives the work of big operations (an executor's time limit). */
962
+ readonly meter?: WorkMeter;
963
+ }
964
+ /**
965
+ * A new session for one run: a fresh Err object, the Rnd generator at VBA's initial seed and its
966
+ * own Like pattern cache.
967
+ */
968
+ declare function createSession(options?: SessionOptions): VbaSession;
969
+ /** The upper-case partner of one code unit (itself when it has none). */
970
+ declare function upperUnit(unit: number): number;
971
+ /** The lower-case partner of one code unit (itself when it has none). */
972
+ declare function lowerUnit(unit: number): number;
973
+ /** `UCase`: the same length, one code unit at a time. */
974
+ declare const toUpper: (s: string) => string;
975
+ /** `LCase`: the same length, one code unit at a time. */
976
+ declare const toLower: (s: string) => string;
977
+ /** `StrConv(s, vbProperCase)`: the first letter of each word upper case, the rest lower case. */
978
+ declare function toProper(s: string): string;
979
+ /** A string's comparison key: three levels, compared in order. */
980
+ interface CollationKey {
981
+ /** Primary units (folded letters, digits and symbols). */
982
+ readonly primary: string;
983
+ /** Combining marks per primary position: the accents. */
984
+ readonly marks: readonly string[];
985
+ /** The ignored hyphens and apostrophes as [position, unit] pairs: the tie-break. */
986
+ readonly special: readonly (readonly [number, number])[];
987
+ }
988
+ /** The comparison key of a string under Option Compare Text. */
989
+ declare function collationKey(s: string): CollationKey;
990
+ /** Compares two keys: -1, 0 or 1. */
991
+ declare function compareKeys(a: CollationKey, b: CollationKey): -1 | 0 | 1;
992
+ /** Compares two strings under Option Compare Text: -1, 0 or 1. */
993
+ declare function textCompare(a: string, b: string): -1 | 0 | 1;
994
+ /** A string equal for exactly the strings `textCompare` finds equal (Collection keys). */
995
+ declare function textKey(s: string): string;
996
+ /** A string prepared for searching: its folded letters and where each came from. */
997
+ declare class SearchText {
998
+ /** The folded letters. */
999
+ readonly text: string;
1000
+ /** `starts[i]` is the letter index where source character `i` begins (`starts[n]` the end). */
1001
+ private readonly starts;
1002
+ /** `origin[k]` is the source character letter `k` belongs to. */
1003
+ private readonly origin;
1004
+ private constructor();
1005
+ /** Prepares `s` for the compare mode (binary keeps it as it is). */
1006
+ static of(s: string, compare: CompareMode): SearchText;
1007
+ /** The source length (in code units). */
1008
+ get sourceLength(): number;
1009
+ /** The letter index where source character `i` begins. */
1010
+ letterAt(i: number): number;
1011
+ /** The source character letter `k` belongs to. */
1012
+ sourceAt(k: number): number;
1013
+ private isBoundary;
1014
+ /** The first match of `needle` at or after source index `from`: its source index, or -1. */
1015
+ indexOf(needle: SearchText, from: number): number;
1016
+ /**
1017
+ * The last match of `needle` that ends at or before source index `end` (exclusive): its source
1018
+ * index, or -1.
1019
+ */
1020
+ lastIndexOf(needle: SearchText, end: number): number;
1021
+ /**
1022
+ * The first match at or after source index `from` that covers whole source characters, as a
1023
+ * source range [start, end), or undefined.
1024
+ */
1025
+ wholeMatch(needle: SearchText, from: number): {
1026
+ start: number;
1027
+ end: number;
1028
+ } | undefined;
1029
+ /** True when `needle` occurs anywhere. */
1030
+ includes(needle: SearchText): boolean;
1031
+ }
1032
+ /** The number Err.Raise reports for an error number: an HRESULT's VBA equivalent, else itself. */
1033
+ declare function vbaNumberOf(n: number): number;
1034
+ /** The description of a negative (HRESULT) error number. */
1035
+ declare function automationMessage(n: number): string;
1036
+ /** The character of an ANSI (Windows-1252) code. */
1037
+ declare function ansiChar(code: number): string;
1038
+ /**
1039
+ * The ANSI code Windows gives a code unit: its Windows-1252 code, else its best fit
1040
+ * ("Ā" is 65, "A"; "Σ" is 83, "S"), else 63 ("?").
1041
+ */
1042
+ declare function ansiCode(unit: number): number;
1043
+ /** A string as it survives a round trip through the ANSI code page (StrConv's case modes). */
1044
+ declare function ansiRoundTrip(s: string): string;
1045
+ /** The largest Currency, as a count of ten-thousandths (922,337,203,685,477.5807). */
1046
+ declare const CUR_MAX = 9223372036854775807n;
1047
+ /** The smallest Currency, as a count of ten-thousandths (-922,337,203,685,477.5808). */
1048
+ declare const CUR_MIN = -9223372036854775808n;
1049
+ /** A finite double rounded half to even to an integer. */
1050
+ declare function roundEven(x: number): number;
1051
+ /** Currency from a double, rounded half to even to four decimals from its exact value. */
1052
+ declare function curFromNumber(x: number): bigint;
1053
+ /** A Currency (a count of ten-thousandths) as a Double. */
1054
+ declare const curToNumber: (v: bigint) => number;
1055
+ /** A Decimal value: `m / 10^s`. */
1056
+ interface Dec {
1057
+ /** The signed integer mantissa, its absolute value less than 2^96. */
1058
+ readonly m: bigint;
1059
+ /** The scale: the number of decimal places, 0 to 28. */
1060
+ readonly s: number;
1061
+ }
1062
+ /** Decimal from a double: rounded to 15 significant digits first, as Office converts. */
1063
+ declare function decFromNumber(x: number, digits?: number): Dec;
1064
+ /** Decimal from a plain decimal string ("-12.5", "1.5e-3"); the caller validated the syntax. */
1065
+ declare function decFromString(text: string): Dec;
1066
+ /** A Decimal as the nearest Double. */
1067
+ declare function decToNumber(d: Dec): number;
1068
+ /** Plain digits with "." as the decimal symbol, trailing zeros removed. */
1069
+ declare function decToString(d: Dec): string;
1070
+ /** Plain digits of a Currency with "." and no trailing zeros. */
1071
+ declare const curToString: (v: bigint) => string;
1072
+ /**
1073
+ * A double or single as VBA's `CStr` writes it: at most `maxDigits` (15 or 7) significant digits,
1074
+ * trailing zeros removed, scientific notation (`1.5E+20`, `1E-07`) when the digits do not fit.
1075
+ */
1076
+ declare function floatToStr(x: number, maxDigits?: number, decimal?: string): string;
1077
+ /** A parsed number: `m * 10^-s` (`s` may be negative). */
1078
+ interface ParsedNum {
1079
+ /** The integer mantissa. */
1080
+ readonly m: bigint;
1081
+ /** The scale: the value is `m * 10^-s`. */
1082
+ readonly s: number;
1083
+ /**
1084
+ * The text's order of magnitude as Office checks it: the integer digits it spells (leading
1085
+ * zeros dropped, at least one) plus its exponent. "0E10" has order 11, too big for a Long even
1086
+ * though it is zero.
1087
+ */
1088
+ readonly order: number;
1089
+ /** `&H`/`&O` text: `m` is the unsigned value, which each destination wraps to its width. */
1090
+ readonly radix?: boolean;
1091
+ /** `&H`/`&O` text wider than 64 bits. */
1092
+ readonly radixOverflow?: boolean;
1093
+ }
1094
+ /**
1095
+ * Parses a numeric-coercion string: `[WS] [sign [WS]] number [exponent] [WS]`, where the number
1096
+ * may carry the locale's grouping and currency symbols, parentheses for negatives, or a trailing
1097
+ * sign. The exponent is written without spaces ("1 E 5" is not a number). Undefined when the text
1098
+ * is not a number.
1099
+ */
1100
+ declare function parseNum(input: string, loc: VbaLocale): ParsedNum | undefined;
1101
+ /** The nearest double to a parsed number (radix text as a signed 32- or 64-bit value). */
1102
+ declare function parsedToNumber(p: ParsedNum): number;
1103
+ /** True when the text converts to a finite Double: what IsNumeric tests for a String. */
1104
+ declare function parsesAsDouble(p: ParsedNum | undefined): boolean;
1105
+ /** The serial of 0100-01-01, the earliest VBA Date. */
1106
+ declare const DATE_MIN = -657434;
1107
+ /** The serial of 9999-12-31 23:59:59, the latest VBA Date. */
1108
+ declare const DATE_MAX = 2958465.999988426;
1109
+ /** The calendar fields of a date serial, as {@link dateParts} returns them. */
1110
+ interface DateParts {
1111
+ /** The year, 100 to 9999 for a valid Date. */
1112
+ year: number;
1113
+ /** The month, 1 to 12. */
1114
+ month: number;
1115
+ /** The day of the month, 1 to 31. */
1116
+ day: number;
1117
+ /** The hour, 0 to 23. */
1118
+ hour: number;
1119
+ /** The minute, 0 to 59. */
1120
+ minute: number;
1121
+ /** The second, 0 to 59. */
1122
+ second: number;
1123
+ /** 1 = Sunday ... 7 = Saturday. */
1124
+ weekday: number;
1125
+ }
1126
+ /** Days from 1970-01-01 of a proleptic Gregorian date (month may be any integer). */
1127
+ declare function daysFromCivil(y: number, m: number, d: number): number;
1128
+ /** The civil date (year, month 1 to 12, day 1 to 31) of a count of days from 1970-01-01. */
1129
+ declare function civilFromDays(z: number): {
1130
+ year: number;
1131
+ month: number;
1132
+ day: number;
1133
+ };
1134
+ /** The serial day number (no time) of a date; months and days may overflow, as DateSerial allows. */
1135
+ declare const serialDay: (year: number, month: number, day: number) => number;
1136
+ /** Combines a day number and a time fraction (0 <= t < 1) into a serial. */
1137
+ declare const combine: (day: number, time: number) => number;
1138
+ /** True when a number is a serial within the Date range (up to the end of 9999-12-31). */
1139
+ declare const isDateSerial: (serial: number) => boolean;
1140
+ /** Raises error 6 when a serial is outside the Date range. */
1141
+ declare function checkDate(serial: number): number;
1142
+ /**
1143
+ * Splits a serial into its day and its time of day in whole seconds, rounded to the second with
1144
+ * an exact half going to even (Office: 10.5 s reads as 10, 11.5 s and 12.5 s as 12).
1145
+ */
1146
+ declare function splitSerial(serial: number): {
1147
+ day: number;
1148
+ seconds: number;
1149
+ };
1150
+ /**
1151
+ * The calendar fields and weekday of a date serial, with the time rounded to the second as
1152
+ * {@link splitSerial} does.
1153
+ */
1154
+ declare function dateParts(serial: number): DateParts;
1155
+ /** A serial from date and time parts (all may overflow their ranges, as DateSerial/TimeSerial). */
1156
+ declare function partsToSerial(year: number, month: number, day: number, hour?: number, minute?: number, second?: number): number;
1157
+ /**
1158
+ * The last year a two-digit year means (Windows' "When a two-digit year is entered" setting,
1159
+ * 2049 by default and on the capture machine): 0..49 is 2000..2049, 50..99 is 1950..1999.
1160
+ */
1161
+ declare const TWO_DIGIT_YEAR_MAX = 2049;
1162
+ /**
1163
+ * Applies the two-digit year window to a year below 100. DateSerial passes negative years too,
1164
+ * and they count back from the window's century (-1 is 1999).
1165
+ */
1166
+ declare function windowYear(y: number, max?: number): number;
1167
+ /**
1168
+ * Formats a serial with the locale pattern codes the regional settings use (`d dd ddd dddd m mm
1169
+ * mmm mmmm yy yyyy h hh m mm s ss AM/PM`); `m` after `h` (or before `s`) is minutes.
1170
+ */
1171
+ declare function formatDatePattern(serial: number, pattern: string, loc?: VbaLocale, padYear?: boolean): string;
1172
+ /**
1173
+ * `CStr` of a Date: the time alone on 1899-12-30, the date alone at midnight, else both. `CStr`
1174
+ * writes the year as it is (100-01-01) where `Format` pads it to four digits (0100-01-01): pass
1175
+ * `padYear` for Format.
1176
+ */
1177
+ declare function dateToStr(serial: number, loc?: VbaLocale, padYear?: boolean): string;
1178
+ /**
1179
+ * Parses a date, a time, or a date and time as CDate and IsDate do. Returns the serial, or
1180
+ * undefined when the text is not a date. Pure numbers are not dates here (CDate falls back to the
1181
+ * number itself). The colon and, unless it separates dates in the locale, the period separate
1182
+ * time fields ("2.5" is 2:05 AM); slashes, hyphens, commas and spaces separate date fields.
1183
+ * Weekday names are refused, as VBA does.
1184
+ * @param year the year a date without one takes (the session's current year).
1185
+ */
1186
+ declare function parseDate(text: string, loc?: VbaLocale, year?: number): number | undefined;
1187
+ /** The first day of the week `vbUseSystemDayOfWeek` (0) resolves to: 1, Sunday, as in en-US. */
1188
+ declare const SYSTEM_FIRST_DAY = 1;
1189
+ /** The first-week rule `vbUseSystem` (0) resolves to: 1, the week of January 1, as in en-US. */
1190
+ declare const SYSTEM_FIRST_WEEK = 1;
1191
+ /** 1..7 relative to `firstDay` (1 = Sunday ... 7 = Saturday; 0 = system). */
1192
+ declare function weekdayOf(serial: number, firstDay?: number): number;
1193
+ /**
1194
+ * The week of the year (1..53). `firstWeek`: 1 the week of January 1, 2 the first week with four
1195
+ * days in the year, 3 the first full week (0 = system). Days before week 1 belong to the last
1196
+ * week of the previous year; with rule 2, days on or after the start of next year's week 1 are
1197
+ * week 1 (rules 1 and 3 keep them in week 52 or 53, as VBA does).
1198
+ *
1199
+ * `formatQuirk` reproduces what `Format`'s "ww" does and `DatePart` does not (observed in Office;
1200
+ * Microsoft's KB Q200299): with Monday weeks and rule 2, a Monday that starts next year's week 1
1201
+ * stays week 53 when the next year is a leap year.
1202
+ */
1203
+ declare function weekOfYear(serial: number, firstDay?: number, firstWeek?: number, formatQuirk?: boolean): number;
1204
+ /**
1205
+ * A date argument as a serial, or undefined for Null (the caller returns Null). A number outside
1206
+ * the Date range is a type mismatch here (Year(3000000) raises 13, not CDate's overflow 6).
1207
+ */
1208
+ declare function dateArg(v: Value, env?: VbaEnv): number | undefined;
1209
+ /** VBA's `Year` function: the year of a date as an Integer; Null for Null. */
1210
+ declare const year: (v: Value, env?: VbaEnv) => Value;
1211
+ /** VBA's `Month` function: the month (1 to 12) as an Integer; Null for Null. */
1212
+ declare const month: (v: Value, env?: VbaEnv) => Value;
1213
+ /** VBA's `Day` function: the day of the month (1 to 31) as an Integer; Null for Null. */
1214
+ declare const day: (v: Value, env?: VbaEnv) => Value;
1215
+ /** VBA's `Hour` function: the hour (0 to 23) as an Integer; Null for Null. */
1216
+ declare const hour: (v: Value, env?: VbaEnv) => Value;
1217
+ /** VBA's `Minute` function: the minute (0 to 59) as an Integer; Null for Null. */
1218
+ declare const minute: (v: Value, env?: VbaEnv) => Value;
1219
+ /** VBA's `Second` function: the second (0 to 59) as an Integer; Null for Null. */
1220
+ declare const second: (v: Value, env?: VbaEnv) => Value;
1221
+ /** A day-of-week argument: 0 (system) .. 7, else error 5. Omitted gives `fallback`. */
1222
+ declare function dayOfWeekArg(v: Value | undefined, fallback: number, env?: VbaEnv): number;
1223
+ /** `Weekday(date, [firstdayofweek = vbSunday])`. */
1224
+ declare function weekday(v: Value, firstDay?: Value, env?: VbaEnv): Value;
1225
+ /**
1226
+ * `DateSerial(year, month, day)`: parts may overflow into the next unit. Months carry into the
1227
+ * year first, and the two-digit window applies to the year that results (so DateSerial(99, 13, 1)
1228
+ * is in year 100, and a negative year counts back from 2000).
1229
+ */
1230
+ declare function dateSerial(y: Value, m: Value, d: Value, env?: VbaEnv): Value;
1231
+ /**
1232
+ * `TimeSerial(hour, minute, second)`: the signed number of seconds as a fraction of a day, so
1233
+ * TimeSerial(-1, 0, 0) is the serial -1/24 (shown as 1:00:00 AM, as a negative serial's time
1234
+ * counts forward).
1235
+ */
1236
+ declare function timeSerial(h: Value, n: Value, s: Value, env?: VbaEnv): Value;
1237
+ /** `DateValue(date)`: the date part of a date string (or date). */
1238
+ declare const dateValue: (v: Value, env?: VbaEnv) => Value;
1239
+ /** `TimeValue(time)`: the time part of a time string (or date). */
1240
+ declare const timeValue: (v: Value, env?: VbaEnv) => Value;
1241
+ /** `WeekdayName(weekday, [abbreviate], [firstdayofweek = vbUseSystemDayOfWeek])`. */
1242
+ declare function weekdayName(weekdayNo: Value, abbreviate?: Value, firstDay?: Value, env?: VbaEnv): Value;
1243
+ /** `MonthName(month, [abbreviate])`. */
1244
+ declare function monthName(monthNo: Value, abbreviate?: Value, env?: VbaEnv): Value;
1245
+ /** `Now`: the environment clock's local date and time, to the second. */
1246
+ declare const now: (env?: VbaEnv) => Value;
1247
+ /** `Date`: today. */
1248
+ declare function date(env?: VbaEnv): Value;
1249
+ /** `Time`: the time of day. */
1250
+ declare function time(env?: VbaEnv): Value;
1251
+ /** Seconds since local midnight, to the hundredth: `Timer`, and the seed Randomize mixes in. */
1252
+ declare function timerSeconds(env?: VbaEnv): number;
1253
+ /** `Timer`: seconds since midnight as a Single, with hundredths. */
1254
+ declare const timer: (env?: VbaEnv) => Value;
1255
+ /** `Date$`: "mm-dd-yyyy". */
1256
+ declare function dateS(env?: VbaEnv): Value;
1257
+ /** `Time$`: "hh:mm:ss" (24-hour). */
1258
+ declare function timeS(env?: VbaEnv): Value;
1259
+ /** A serial as a continuous count of days (the time always moves forward). */
1260
+ declare const linear: (serial: number) => number;
1261
+ /** The serial of a continuous day count. */
1262
+ declare function fromLinear(x: number): number;
1263
+ /** `DateAdd(interval, number, date)`. */
1264
+ declare function dateAdd(interval: Value, number: Value, date: Value, env?: VbaEnv): Value;
1265
+ /** `DateDiff(interval, date1, date2, [firstdayofweek], [firstweekofyear])`: a Long. */
1266
+ declare function dateDiff(interval: Value, date1: Value, date2: Value, firstDay?: Value, firstWeek?: Value, env?: VbaEnv): Value;
1267
+ /** `DatePart(interval, date, [firstdayofweek], [firstweekofyear])`: an Integer. */
1268
+ declare function datePart(interval: Value, date: Value, firstDay?: Value, firstWeek?: Value, env?: VbaEnv): Value;
1269
+ /** `FormatNumber(expr, [digits], [leading], [parens], [group])`. */
1270
+ declare function formatNumber(expr: Value, digits?: Value, leading?: Value, parens?: Value, grouped?: Value, env?: VbaEnv): Value;
1271
+ /** `FormatCurrency(expr, [digits], [leading], [parens], [group])`. */
1272
+ declare function formatCurrency(expr: Value, digits?: Value, leading?: Value, parens?: Value, grouped?: Value, env?: VbaEnv): Value;
1273
+ /** `FormatPercent(expr, [digits], [leading], [parens], [group])`: the value times 100, with "%". */
1274
+ declare function formatPercent(expr: Value, digits?: Value, leading?: Value, parens?: Value, grouped?: Value, env?: VbaEnv): Value;
1275
+ /** `FormatDateTime(date, [namedFormat])`: 0 general, 1 long date, 2 short date, 3 long time, 4 short time. */
1276
+ declare function formatDateTime(expr: Value, namedFormat?: Value, env?: VbaEnv): Value;
1277
+ /**
1278
+ * Formats a value with a format string: the pure core of Format, for executors that hold JS
1279
+ * values. `firstDay` and `firstWeek` are the VbDayOfWeek and VbFirstWeekOfYear numbers.
1280
+ */
1281
+ declare function formatValue(value: Value, fmt: string, firstDay: number, firstWeek: number, env?: VbaEnv): string;
1282
+ /** `Format(expr, [format], [firstdayofweek], [firstweekofyear])`: a Variant String. */
1283
+ declare const format: (expr: Value, fmt?: Value, firstDayOfWeek?: Value, firstWeekOfYear?: Value, env?: VbaEnv) => Value;
1284
+ /** `Format$`: the same text as a String. */
1285
+ declare const formatS: (expr: Value, fmt?: Value, firstDayOfWeek?: Value, firstWeekOfYear?: Value, env?: VbaEnv) => Value;
1286
+ /** VBA's `Atn` function: the arctangent in radians, as a Double. Null raises error 94. */
1287
+ declare const atn: (v: Value, env?: VbaEnv) => Value;
1288
+ /** VBA's `Cos` function, as a Double. Error 5 for an argument of 2^63 or more in size. */
1289
+ declare const cos: (v: Value, env?: VbaEnv) => Value;
1290
+ /** VBA's `Sin` function, as a Double. Error 5 for an argument of 2^63 or more in size. */
1291
+ declare const sin: (v: Value, env?: VbaEnv) => Value;
1292
+ /** VBA's `Tan` function, as a Double. Error 5 for an argument of 2^63 or more in size. */
1293
+ declare const tan: (v: Value, env?: VbaEnv) => Value;
1294
+ /** VBA's `Exp` function, as a Double. A result too large for a Double raises error 6. */
1295
+ declare const exp: (v: Value, env?: VbaEnv) => Value;
1296
+ /** VBA's `Log` function (natural logarithm), as a Double. Error 5 unless the argument is over 0. */
1297
+ declare const log: (v: Value, env?: VbaEnv) => Value;
1298
+ /** VBA's `Sqr` function (square root), as a Double. Error 5 for a negative argument. */
1299
+ declare const sqr: (v: Value, env?: VbaEnv) => Value;
1300
+ /** `Sgn(number)`: -1, 0 or 1 as an Integer. */
1301
+ declare function sgn(v: Value, env?: VbaEnv): Value;
1302
+ /** `Abs(number)`, keeping the type (so Abs of the smallest Integer or Long overflows). */
1303
+ declare function abs(v: Value, env?: VbaEnv): Value;
1304
+ /** `Fix(number)`: truncates toward zero. */
1305
+ declare const fix: (v: Value, env?: VbaEnv) => Value;
1306
+ /** `Int(number)`: rounds down. */
1307
+ declare const int: (v: Value, env?: VbaEnv) => Value;
1308
+ /**
1309
+ * Rounds a double half to even at `digits` decimals, working on its shortest decimal form (so
1310
+ * 2.675 is treated as written).
1311
+ */
1312
+ declare function roundDouble(x: number, digits: number): number;
1313
+ /** `Round(number, [numdigitsafterdecimal])`, keeping the type of `number`. */
1314
+ declare function round(v: Value, digits?: Value, env?: VbaEnv): Value;
1315
+ /** The next seed: (seed * 1140671485 + 12820163) mod 2^24, exactly. */
1316
+ declare function nextSeed(seed: number): number;
1317
+ /** `Rnd([number])`: a Single in [0, 1). */
1318
+ declare function rnd(s: VbaSession, number?: Value): Value;
1319
+ /**
1320
+ * `Randomize [number]`: mixes the high 32 bits of the Double into the middle 16 bits of the seed.
1321
+ * Without a number the session clock's `Timer` value is used.
1322
+ */
1323
+ declare function randomize(s: VbaSession, number?: Value): void;
1324
+ /** A finite Double result: an infinite one overflows (error 6), NaN is an invalid call (5). */
1325
+ declare function fin(x: number): Value;
1326
+ /** (1 + rate) ^ nper; an infinite power overflows (error 6) as VBA's does. */
1327
+ declare function growth(rate: number, nper: number): number;
1328
+ /** A financial argument as a JS number (a Double coercion). An internal helper. */
1329
+ declare const num: (v: Value, env: VbaEnv) => number;
1330
+ /**
1331
+ * The future value behind `FV`, on plain numbers. `due` is 0 for payments at the end of each
1332
+ * period and 1 for the beginning. The result is not range-checked; error 6 when the growth
1333
+ * factor overflows.
1334
+ */
1335
+ declare function fvCore(rate: number, nper: number, pmt: number, pv: number, due: number): number;
1336
+ /**
1337
+ * The payment behind `Pmt`, on plain numbers (`due` as in {@link fvCore}). Error 5 when `nper`
1338
+ * is 0.
1339
+ */
1340
+ declare function pmtCore(rate: number, nper: number, pv: number, fv: number, due: number): number;
1341
+ /** `FV(rate, nper, pmt, [pv], [due])`. */
1342
+ declare const fv: (rate: Value, nper: Value, pmt: Value, pv?: Value, due?: Value, env?: VbaEnv) => Value;
1343
+ /** `PV(rate, nper, pmt, [fv], [due])`. */
1344
+ declare function pv(rate: Value, nper: Value, pmt: Value, fvArg?: Value, due?: Value, env?: VbaEnv): Value;
1345
+ /** `Pmt(rate, nper, pv, [fv], [due])`. */
1346
+ declare const pmt: (rate: Value, nper: Value, pvArg: Value, fvArg?: Value, due?: Value, env?: VbaEnv) => Value;
1347
+ /**
1348
+ * The interest part of payment `per` behind `IPmt`, on plain numbers (`due` as in
1349
+ * {@link fvCore}). Error 5 unless `per` is at least 1 and less than `nper + 1`.
1350
+ */
1351
+ declare function ipmtCore(rate: number, per: number, nper: number, pv: number, fv: number, due: number): number;
1352
+ /** `IPmt(rate, per, nper, pv, [fv], [due])`. */
1353
+ declare const ipmt: (rate: Value, per: Value, nper: Value, pvArg: Value, fvArg?: Value, due?: Value, env?: VbaEnv) => Value;
1354
+ /** `PPmt(rate, per, nper, pv, [fv], [due])`. */
1355
+ declare function ppmt(rate: Value, per: Value, nper: Value, pvArg: Value, fvArg?: Value, due?: Value, env?: VbaEnv): Value;
1356
+ /** `NPer(rate, pmt, pv, [fv], [due])`. */
1357
+ declare function nper(rate: Value, pmtArg: Value, pvArg: Value, fvArg?: Value, due?: Value, env?: VbaEnv): Value;
1358
+ /** `SLN(cost, salvage, life)`. */
1359
+ declare function sln(cost: Value, salvage: Value, life: Value, env?: VbaEnv): Value;
1360
+ /** `SYD(cost, salvage, life, period)`. */
1361
+ declare function syd(cost: Value, salvage: Value, life: Value, period: Value, env?: VbaEnv): Value;
1362
+ /** `DDB(cost, salvage, life, period, [factor = 2])`. */
1363
+ declare function ddb(cost: Value, salvage: Value, life: Value, period: Value, factor?: Value, env?: VbaEnv): Value;
1364
+ /** The cash flows of a one-dimensional numeric array argument. */
1365
+ declare function cashFlows(v: Value, env: VbaEnv): number[];
1366
+ /** `NPV(rate, values())`. */
1367
+ declare function npv(rate: Value, values: Value, env?: VbaEnv): Value;
1368
+ /** `IRR(values(), [guess = 0.1])`. */
1369
+ declare function irr(values: Value, guess?: Value, env?: VbaEnv): Value;
1370
+ /** `MIRR(values(), finance_rate, reinvest_rate)`. */
1371
+ declare function mirr(values: Value, financeRate: Value, reinvestRate: Value, env?: VbaEnv): Value;
1372
+ /** `Rate(nper, pmt, pv, [fv], [due], [guess = 0.1])`. */
1373
+ declare function rate(nper: Value, pmt: Value, pv: Value, fv?: Value, due?: Value, guess?: Value, env?: VbaEnv): Value;
1374
+ /** Any value as an integer (half to even) within [min, max], else error 6. */
1375
+ declare function toBigInt(v: Value, min: bigint, max: bigint, env?: VbaEnv, maxOrder?: number): bigint;
1376
+ /** Let-coercion to Integer (half to even); error 6 outside -32768 to 32767. */
1377
+ declare const toInt: (v: Value, env?: VbaEnv) => number;
1378
+ /** Let-coercion to Long (half to even); error 6 outside the 32-bit signed range. */
1379
+ declare const toLng: (v: Value, env?: VbaEnv) => number;
1380
+ /** Let-coercion to Byte (half to even); error 6 outside 0 to 255. True is 255. */
1381
+ declare const toByte: (v: Value, env?: VbaEnv) => number;
1382
+ /** Let-coercion to LongLong (half to even); error 6 outside the 64-bit signed range. */
1383
+ declare const toLLng: (v: Value, env?: VbaEnv) => bigint;
1384
+ /**
1385
+ * Let-coercion to Double: True is -1, Empty 0, a String is parsed with the locale's settings.
1386
+ * Null raises error 94, a value of the wrong kind error 13, a String out of range error 6.
1387
+ */
1388
+ declare function toDbl(v: Value, env?: VbaEnv): number;
1389
+ /** Let-coercion to Single, as {@link toDbl} then rounded; error 6 out of Single range. */
1390
+ declare function toSng(v: Value, env?: VbaEnv): number;
1391
+ /** Let-coercion to Currency, as a count of ten-thousandths; error 6 out of range. */
1392
+ declare function toCur(v: Value, env?: VbaEnv): bigint;
1393
+ /** Let-coercion to Decimal, as a {@link Dec}; error 6 out of range. */
1394
+ declare function toDec(v: Value, env?: VbaEnv): Dec;
1395
+ /** The Boolean a String spells: "True"/"False" (any case, trimmed), the locale's names, #TRUE#. */
1396
+ declare function boolText(s: string, env?: VbaEnv): boolean | undefined;
1397
+ /**
1398
+ * Let-coercion to Boolean: a number is True when it is not 0; a String reads as "True", "False"
1399
+ * or the locale's names (see {@link boolText}) or else as a number; Empty is False. Null raises
1400
+ * error 94 and a value of the wrong kind error 13.
1401
+ */
1402
+ declare function toBool(v: Value, env?: VbaEnv): boolean;
1403
+ /**
1404
+ * A Date serial. A String reads as a date or time (a date without a year takes the current year
1405
+ * of the environment's clock), else as a number within the Date range. Outside it, a String or a
1406
+ * Variant number raises 13 and a `typed` number (a literal or a variable of a declared numeric
1407
+ * type) raises 6: CDate("3000000") and CDate(x) with `x = 3000000` in a Variant are 13,
1408
+ * CDate(3000000) is 6.
1409
+ */
1410
+ declare function toDate(v: Value, env?: VbaEnv, typed?: boolean): number;
1411
+ /**
1412
+ * Let-coercion to String: numbers use the locale's decimal symbol (Single with 7 significant
1413
+ * digits, Double with 15), a Date as {@link dateToStr} writes it, a Boolean "True" or "False",
1414
+ * an Error value "Error n" and Empty "". Null raises error 94; an object reads through its
1415
+ * default member.
1416
+ */
1417
+ declare function toStr(v: Value, env?: VbaEnv): string;
1418
+ /** `CVErr` / Let-coercion to Error: a Long between 0 and 65535, else error 5. */
1419
+ declare function toErr(v: Value, env?: VbaEnv): Value;
1420
+ /**
1421
+ * Let-coerces a value to a declared scalar type (`VT.*`): assignment to a typed variable, field
1422
+ * or element, and operand conversion. `VT.Variant` returns the value itself (an object reads
1423
+ * through its default member). An Error value only goes to Variant or Error; any other type,
1424
+ * String included, raises 13. `typed` is true when the source has a declared type other than
1425
+ * Variant (a literal, a typed variable or expression); it only changes the error a number outside
1426
+ * the Date range raises (6 typed, 13 from a Variant).
1427
+ */
1428
+ declare function letAs(vt: number, v: Value, env?: VbaEnv, typed?: boolean): Value;
1429
+ /**
1430
+ * The C* conversion functions (CInt, CStr, ...): `letAs`, except that an Error value converts to
1431
+ * its code for the numeric types and Boolean and to "Error n" for String, while CDec and CDate of
1432
+ * an Error raise 13 (observed in Office).
1433
+ */
1434
+ declare function convert(vt: number, v: Value, env?: VbaEnv, typed?: boolean): Value;
1435
+ /** A Double that is out of Double range raises 6 (for results of float arithmetic). */
1436
+ declare function checkDbl(x: number): number;
1437
+ /** The initial value of a `String * n`: n NUL characters (Office: Asc(s) is 0, Len(s) is n). */
1438
+ declare const fixedInit: (n: number) => string;
1439
+ /** Pads or truncates a string to a fixed length (`String * n`, [MS-VBAL] 5.5.1.2.5). */
1440
+ declare const fixLen: (s: string, n: number) => string;
1441
+ /** The operand's type for the tables: Boolean counts as Integer, String as Double, Empty as 0. */
1442
+ declare function typing(v: Value): number;
1443
+ /** The effective value type of a binary arithmetic operator ([MS-VBAL] 5.6.9.3). */
1444
+ declare function binType(a: number, b: number): number;
1445
+ /** `a & b` ([MS-VBAL] 5.6.9.4): Null only when both are Null. */
1446
+ declare function cat(a: Value, b: Value, env?: VbaEnv): Value;
1447
+ /** A string from UTF-16LE bytes (a trailing odd byte is dropped), as `Byte()` to String. */
1448
+ declare function bytesToStr(bytes: readonly number[]): string;
1449
+ /** `a + b`: addition, or concatenation of two strings. */
1450
+ declare function add(a: Value, b: Value, strict?: boolean, env?: VbaEnv): Value;
1451
+ /** `a - b`: subtraction. Null if either operand is Null; two Dates give a Double. */
1452
+ declare function sub(a: Value, b: Value, strict?: boolean, env?: VbaEnv): Value;
1453
+ /** `a * b`: multiplication. Null if either operand is Null. */
1454
+ declare function mul(a: Value, b: Value, strict?: boolean, env?: VbaEnv): Value;
1455
+ /** `a / b` ([MS-VBAL] 5.6.9.3.5). */
1456
+ declare function div(a: Value, b: Value, strict?: boolean, env?: VbaEnv): Value;
1457
+ /** `a \ b`: integer division, truncating toward zero. */
1458
+ declare const idiv: (a: Value, b: Value, strict?: boolean, env?: VbaEnv) => Value;
1459
+ /** `a Mod b`: the remainder, with the sign of `a`; operands are rounded half to even first. */
1460
+ declare const mod: (a: Value, b: Value, strict?: boolean, env?: VbaEnv) => Value;
1461
+ /** `a ^ b` ([MS-VBAL] 5.6.9.3.7): always a Double. */
1462
+ declare function pow(a: Value, b: Value, env?: VbaEnv): Value;
1463
+ /** Unary `-a` ([MS-VBAL] 5.6.9.3.1). */
1464
+ declare function neg(a: Value, strict?: boolean, env?: VbaEnv): Value;
1465
+ /** Binary comparison: UTF-16 code units in order, the longer string greater. */
1466
+ declare function binaryCompare(a: string, b: string): -1 | 0 | 1;
1467
+ /** Compares two strings under a compare mode: -1, 0 or 1. */
1468
+ declare const strCompare: (a: string, b: string, compare?: CompareMode) => -1 | 0 | 1;
1469
+ /**
1470
+ * Compares two values: -1, 0 or 1, or `null` when either is Null. Arrays, UDTs and an Error
1471
+ * against a non-Error raise error 13. When the comparison type cannot hold a number operand
1472
+ * (CCur(1) < 1E+20, #1/1/2000# < 1E+10), the two compare as Doubles, as Office does; a String
1473
+ * operand that does not fit still raises its error.
1474
+ */
1475
+ declare function cmp(a: Value, b: Value, compare?: CompareMode, typed?: boolean, env?: VbaEnv): -1 | 0 | 1 | null;
1476
+ /**
1477
+ * `a = b`: a Boolean, or Null when either operand is Null. `compare` is the module's Option
1478
+ * Compare and `typed` is true when an operand has a declared type other than Variant (see
1479
+ * {@link cmp}).
1480
+ */
1481
+ declare const eq: (a: Value, b: Value, compare?: CompareMode, typed?: boolean, env?: VbaEnv) => Value;
1482
+ /** `a <> b`, with the arguments of {@link eq}. */
1483
+ declare const ne: (a: Value, b: Value, compare?: CompareMode, typed?: boolean, env?: VbaEnv) => Value;
1484
+ /** `a < b`, with the arguments of {@link eq}. */
1485
+ declare const lt: (a: Value, b: Value, compare?: CompareMode, typed?: boolean, env?: VbaEnv) => Value;
1486
+ /** `a <= b`, with the arguments of {@link eq}. */
1487
+ declare const le: (a: Value, b: Value, compare?: CompareMode, typed?: boolean, env?: VbaEnv) => Value;
1488
+ /** `a > b`, with the arguments of {@link eq}. */
1489
+ declare const gt: (a: Value, b: Value, compare?: CompareMode, typed?: boolean, env?: VbaEnv) => Value;
1490
+ /** `a >= b`, with the arguments of {@link eq}. */
1491
+ declare const ge: (a: Value, b: Value, compare?: CompareMode, typed?: boolean, env?: VbaEnv) => Value;
1492
+ /**
1493
+ * `a And b`: logical and bitwise conjunction. Booleans give a Boolean, other operands work on
1494
+ * their Byte, Integer, Long or LongLong bits. `Null And 0` is 0 and `Null And False` is False;
1495
+ * any other And with Null is Null. `strict` is true when
1496
+ * neither operand is declared Variant.
1497
+ */
1498
+ declare const and: (a: Value, b: Value, strict?: boolean, env?: VbaEnv) => Value;
1499
+ /** `a Or b`: logical and bitwise disjunction, with the arguments of {@link and}. */
1500
+ declare const or: (a: Value, b: Value, strict?: boolean, env?: VbaEnv) => Value;
1501
+ /** `a Xor b`: exclusive or, with the arguments of {@link and}. Null if either is Null. */
1502
+ declare const xor: (a: Value, b: Value, strict?: boolean, env?: VbaEnv) => Value;
1503
+ /** `a Eqv b`: equivalence, with the arguments of {@link and}. Null if either is Null. */
1504
+ declare const eqv: (a: Value, b: Value, strict?: boolean, env?: VbaEnv) => Value;
1505
+ /** `a Imp b`: implication, with the arguments of {@link and}. */
1506
+ declare const imp: (a: Value, b: Value, strict?: boolean, env?: VbaEnv) => Value;
1507
+ /** `Not a`. */
1508
+ declare function not(a: Value, strict?: boolean, env?: VbaEnv): Value;
1509
+ /**
1510
+ * The truth of an `If`, `While` or `Until` condition. Null counts as False (VBA takes the Else
1511
+ * branch); anything that does not convert raises error 13.
1512
+ */
1513
+ declare function cond(v: Value, env?: VbaEnv): boolean;
1514
+ /** Tests `source Like pattern` as JS strings. */
1515
+ declare function likeMatch(source: string, pattern: string, compare?: CompareMode, env?: VbaEnv): boolean;
1516
+ /** `a Like b`: Null when either operand is Null. */
1517
+ declare function like(a: Value, b: Value, compare?: CompareMode, env?: VbaEnv): Value;
1518
+ /** `LSet target = source` for records: the source's image, padded with spaces or cut to size. */
1519
+ declare function lsetRecord(target: Udt, source: Value): void;
1520
+ /**
1521
+ * One member of a {@link ClassDef}: the accessors it supports, each given the object's state
1522
+ * `self`. A missing accessor raises error 438 when the member has no other access, else 394
1523
+ * (Get of a write-only property) or 383 (Let or Set of a read-only property).
1524
+ */
1525
+ interface MemberDef<S> {
1526
+ /** Property Get, or a Function's result. */
1527
+ get?(self: S, args: readonly Value[]): MaybePromise<Value>;
1528
+ /** Property Let: `obj.Name(args) = value`. */
1529
+ let?(self: S, args: readonly Value[], value: Value): MaybePromise<void>;
1530
+ /** Property Set: `Set obj.Name(args) = object`. */
1531
+ set?(self: S, args: readonly Value[], value: VObj): MaybePromise<void>;
1532
+ /** A method; when absent, a call falls back to `get` (a Function called as a statement). */
1533
+ call?(self: S, args: readonly Value[]): MaybePromise<Value>;
1534
+ /**
1535
+ * Parameter names in order, so named arguments can be placed (`What:=`). More arguments than
1536
+ * parameters raise 450.
1537
+ */
1538
+ params?: readonly string[];
1539
+ /** How many leading parameters are required; fewer arguments raise 450 (wrong number). */
1540
+ required?: number;
1541
+ }
1542
+ /** The declaration of a host class for {@link hostClass}. `S` is the state of each object. */
1543
+ interface ClassDef<S> {
1544
+ /** The class name `TypeName` returns. */
1545
+ readonly name: string;
1546
+ /** The members by name; lookups ignore case. */
1547
+ readonly members: Readonly<Record<string, MemberDef<S>>>;
1548
+ /** The default member's name (`obj(1)` is `obj.Item(1)` for "Item"). */
1549
+ readonly defaultMember?: string;
1550
+ /** The items of `For Each`; without it `For Each` raises error 438. */
1551
+ enumerate?(self: S): Iterable<Value> | AsyncIterable<Value>;
1552
+ /** The identity `Is` compares (see {@link VbaObject}). */
1553
+ identity?(self: S): unknown;
1554
+ /** Subscribes a sink to the object's events; returns the function that unsubscribes. */
1555
+ connect?(self: S, sink: EventSink): () => void;
1556
+ }
1557
+ /**
1558
+ * Places named arguments after the positional ones by parameter name, filling gaps with
1559
+ * {@link MISSING}. Error 448 for an unknown name, 446 when the member declares no parameters.
1560
+ */
1561
+ declare function placeArgs(args: readonly Value[], named: NamedArgs | undefined, params: readonly string[] | undefined): Value[];
1562
+ /** Builds host objects of one class: `const make = hostClass(def); const obj = make(state)`. */
1563
+ declare function hostClass<S>(def: ClassDef<S>): (state: S) => VbaObject;
1564
+ interface Entry {
1565
+ readonly key: string | undefined;
1566
+ readonly value: Value;
1567
+ }
1568
+ /**
1569
+ * The state behind one VBA `Collection` object ([MS-VBAL] 6.1.3.1): an ordered list of items
1570
+ * with optional string keys. Keys match as `Option Compare Text` strings do. Errors follow VBA:
1571
+ * 457 for a duplicate key, 13 for a key that is not a String, 5 for an unknown key or any index
1572
+ * of an empty collection, 9 for an index out of range, 7 past the item limit.
1573
+ */
1574
+ declare class CollectionState {
1575
+ readonly env: VbaEnv;
1576
+ /** The items in order, each with its key (if any). */
1577
+ readonly entries: Entry[];
1578
+ /** The keyed entries, by their text-compare key. */
1579
+ readonly keys: Map<string, Entry>;
1580
+ /** @param env the environment for index conversion and the item limit. */
1581
+ constructor(env?: VbaEnv);
1582
+ /** The entry a key names (error 5 when there is none). */
1583
+ private keyed;
1584
+ /** The 0-based position an Index argument names (a number, or a key string). */
1585
+ position(index: Value, missing: number): number;
1586
+ /**
1587
+ * `Collection.Add item, [key], [before], [after]`: stores a copy of an array or UDT item.
1588
+ * Giving both `before` and `after` raises error 5.
1589
+ */
1590
+ add(item: Value, key?: Value, before?: Value, after?: Value): void;
1591
+ /** The item an index names; a key is found without scanning. */
1592
+ item(index: Value): Value;
1593
+ /** `Collection.Remove index`: by 1-based position or by key. */
1594
+ remove(index: Value): void;
1595
+ }
1596
+ /** `New Collection`. */
1597
+ declare function newCollection(env?: VbaEnv): Value;
1598
+ /** The object of a new Collection, for hosts that build their own. */
1599
+ declare const collectionObject: (env?: VbaEnv) => VbaObject;
1600
+ interface Counted {
1601
+ retain(): void;
1602
+ release(): void;
1603
+ /** The object is now held somewhere references are not counted. */
1604
+ escape(): void;
1605
+ }
1606
+ /** Marks an object as reference counted. */
1607
+ declare const counted: <T extends Counted>(o: T) => T;
1608
+ declare function retain(v: Value): void;
1609
+ declare function release(v: Value): void;
1610
+ declare function escape(v: Value): void;
1611
+ /** Marks a store that counts the references it keeps (a Collection): pass it values unescaped. */
1612
+ declare const countsReferences: <T extends object>(o: T) => T;
1613
+ declare const isCountingStore: (o: object) => boolean;
1614
+ /**
1615
+ * Objects waiting for the end of a statement. Each entry records the call depth and the order in
1616
+ * which it was queued: a statement of a frame collects what was queued at its depth or deeper since
1617
+ * the frame began, so a temporary its caller still holds (a function result, an argument) is not
1618
+ * collected by a sibling call.
1619
+ */
1620
+ declare class TerminationQueue<T> {
1621
+ private items;
1622
+ private seq;
1623
+ get size(): number;
1624
+ /** The position the next entry gets: a frame records it when it starts. */
1625
+ get mark(): number;
1626
+ push(o: T, depth: number): void;
1627
+ /** Removes and returns what a statement at `depth`, in a frame begun at `since`, collects. */
1628
+ take(depth: number, since: number): T[];
1629
+ }
1630
+ declare class ForEachCursor {
1631
+ /** The element `next` moved to. */
1632
+ current: Value;
1633
+ /**
1634
+ * A loop whose start failed (an unallocated array raises 92): when Resume Next continues into
1635
+ * it, the body runs once without an element, then the loop ends, as in Office.
1636
+ */
1637
+ broken: boolean;
1638
+ private array;
1639
+ private i;
1640
+ private items;
1641
+ private closed;
1642
+ /**
1643
+ * Starts the loop over a value: an array (92 when unallocated), or an object that enumerates
1644
+ * (438 otherwise). Empty and other non-objects raise 424, anything else 13.
1645
+ */
1646
+ constructor(source: Value | VbaArray);
1647
+ /** The cursor a failed start leaves for Resume Next: one pass of the body, then the end. */
1648
+ static broken(): ForEachCursor;
1649
+ /** Moves to the next element: false at the end (the cursor is then closed). */
1650
+ next: () => MaybePromise<boolean>;
1651
+ /** Ends the loop early (Exit For, an error, the procedure ends): unlocks, returns the iterator. */
1652
+ close: () => void;
1653
+ }
1654
+ /** `o.name(args) = value`, falling back to the default member of what the member returns. */
1655
+ declare function letMember(o: VbaObject, name: string, args: readonly Value[], value: Value,
1656
+ /** Lets the default member of the returned object (an executor may route its own objects). */
1657
+ letDefault?: (target: VbaObject, value: Value) => MaybePromise<void>): MaybePromise<void>;
1658
+ /** What an executor knows of one of its own class instances. */
1659
+ interface ClassFacts {
1660
+ readonly name: string;
1661
+ /** The interfaces the class implements (`Implements IShape`). */
1662
+ readonly implements: readonly string[];
1663
+ }
1664
+ /**
1665
+ * `TypeOf v Is name`: error 424 for a non-object, 91 for Nothing. Only the last part of a dotted
1666
+ * name (`Excel.Range`, `VBAProject.Class1`) is compared, case-insensitively; `Object` matches
1667
+ * every object. `classOf` answers for the executor's class instances (null for a host object).
1668
+ */
1669
+ declare function typeIs(v: Value, name: string, classOf?: (o: VbaObject) => ClassFacts | null): boolean;
1670
+ /** The type name of a declared element type (for `TypeName` of arrays). */
1671
+ declare const vtName: (vt: number) => string;
1672
+ /** `TypeName(v)` as a JS string. */
1673
+ declare function typeNameOf(v: Value): string;
1674
+ /** VBA's `TypeName` function: the type name of a value as a String (see {@link typeNameOf}). */
1675
+ declare const typeName: (v: Value) => Value;
1676
+ /**
1677
+ * `VarType(v)`: arrays add vbArray (8192) to their element type. An object reports its default
1678
+ * member's type (a Range holding 5 is 5, an empty one 0); one without a default member reports 9.
1679
+ */
1680
+ declare function varType(v: Value): Value;
1681
+ /**
1682
+ * VBA's `IsArray` function, as a Boolean value. IsArray, IsEmpty, IsNull, IsError, IsNumeric and
1683
+ * IsDate read an object's default member, as Office does (`IsEmpty(Range("A1"))` tests the
1684
+ * cell); TypeName and IsObject see the object itself.
1685
+ */
1686
+ declare const isArray: (v: Value) => Value;
1687
+ /** VBA's `IsEmpty` function, as a Boolean value; reads an object's default member. */
1688
+ declare const isEmpty: (v: Value) => Value;
1689
+ /** VBA's `IsNull` function, as a Boolean value; reads an object's default member. */
1690
+ declare const isNull: (v: Value) => Value;
1691
+ /** VBA's `IsError` function, as a Boolean value; reads an object's default member. */
1692
+ declare const isError: (v: Value) => Value;
1693
+ /** VBA's `IsObject` function: True for an object reference, `Nothing` included. */
1694
+ declare const isObject: (v: Value) => Value;
1695
+ /** VBA's `IsMissing` function: True for the value of an omitted optional Variant argument. */
1696
+ declare const isMissing: (v: Value) => Value;
1697
+ /** `IsNumeric(v)`: numbers, Empty, Booleans and strings that convert to a number. */
1698
+ declare function isNumeric(v: Value, env?: VbaEnv): Value;
1699
+ /** `IsDate(v)`: a Date, or a string that reads as a date or time. */
1700
+ declare function isDate(v: Value, env?: VbaEnv): Value;
1701
+ /** `QBColor(n)`: the RGB value of one of the 16 QuickBASIC colours. */
1702
+ declare function qbColor(color: Value, env?: VbaEnv): Value;
1703
+ /** `RGB(r, g, b)`: components are clamped to 0..255; the result is &HBBGGRR. */
1704
+ declare function rgb(r: Value, g: Value, b: Value, env?: VbaEnv): Value;
1705
+ /** `Len(s)`: the length of the string form; Null gives Null. */
1706
+ declare function len(v: Value, env?: VbaEnv): Value;
1707
+ /** `LenB(s)`: bytes in the UTF-16 form. */
1708
+ declare function lenB(v: Value, env?: VbaEnv): Value;
1709
+ /** The storage size `Len` reports for a variable of a declared non-Variant type. */
1710
+ declare function lenOfType(vt: number): Value;
1711
+ /** VBA's `Left` function: the first `n` characters. Null gives Null; a negative `n` is error 5. */
1712
+ declare const left: (v: Value, n: Value, env?: VbaEnv) => Value;
1713
+ /** VBA's `Left$` function: as {@link left}, but Null raises error 94. */
1714
+ declare const leftS: (v: Value, n: Value, env?: VbaEnv) => Value;
1715
+ /** VBA's `Right` function: the last `n` characters. Null gives Null; a negative `n` is error 5. */
1716
+ declare const right: (v: Value, n: Value, env?: VbaEnv) => Value;
1717
+ /** VBA's `Right$` function: as {@link right}, but Null raises error 94. */
1718
+ declare const rightS: (v: Value, n: Value, env?: VbaEnv) => Value;
1719
+ /**
1720
+ * VBA's `Mid` function: `length` characters (or the rest) from the 1-based `start`. Null gives
1721
+ * Null; a `start` less than 1 or a negative `length` raises error 5.
1722
+ */
1723
+ declare const mid: (v: Value, start: Value, length?: Value, env?: VbaEnv) => Value;
1724
+ /** VBA's `Mid$` function: as {@link mid}, but Null raises error 94. */
1725
+ declare const midS: (v: Value, start: Value, length?: Value, env?: VbaEnv) => Value;
1726
+ /**
1727
+ * VBA's `LeftB` function: the first `n` bytes of the UTF-16LE form, rounded down to whole
1728
+ * characters. Null gives Null.
1729
+ */
1730
+ declare const leftB: (v: Value, n: Value, env?: VbaEnv) => Value;
1731
+ /** VBA's `RightB` function: the last `n` bytes, rounded down to whole characters. */
1732
+ declare const rightB: (v: Value, n: Value, env?: VbaEnv) => Value;
1733
+ /** VBA's `MidB` function: `Mid` on byte positions, kept to whole characters. */
1734
+ declare const midB: (v: Value, start: Value, length?: Value, env?: VbaEnv) => Value;
1735
+ /**
1736
+ * The `Mid(target, start[, length]) = replacement` statement: returns the new target. Replaces at
1737
+ * most `length` characters and never changes the target's length.
1738
+ */
1739
+ declare function midAssign(target: Value, start: Value, length: Value | undefined, replacement: Value, env?: VbaEnv): Value;
1740
+ /** VBA's `LCase` function. Null gives Null. */
1741
+ declare const lCase: (v: Value, env?: VbaEnv) => Value;
1742
+ /** VBA's `LCase$` function. Null raises error 94. */
1743
+ declare const lCaseS: (v: Value, env?: VbaEnv) => Value;
1744
+ /** VBA's `UCase` function. Null gives Null. */
1745
+ declare const uCase: (v: Value, env?: VbaEnv) => Value;
1746
+ /** VBA's `UCase$` function. Null raises error 94. */
1747
+ declare const uCaseS: (v: Value, env?: VbaEnv) => Value;
1748
+ /** VBA's `Trim` function: removes leading and trailing spaces (only U+0020). Null gives Null. */
1749
+ declare const trim: (v: Value, env?: VbaEnv) => Value;
1750
+ /** VBA's `Trim$` function. Null raises error 94. */
1751
+ declare const trimS: (v: Value, env?: VbaEnv) => Value;
1752
+ /** VBA's `LTrim` function: removes leading spaces. Null gives Null. */
1753
+ declare const lTrim: (v: Value, env?: VbaEnv) => Value;
1754
+ /** VBA's `LTrim$` function. Null raises error 94. */
1755
+ declare const lTrimS: (v: Value, env?: VbaEnv) => Value;
1756
+ /** VBA's `RTrim` function: removes trailing spaces. Null gives Null. */
1757
+ declare const rTrim: (v: Value, env?: VbaEnv) => Value;
1758
+ /** VBA's `RTrim$` function. Null raises error 94. */
1759
+ declare const rTrimS: (v: Value, env?: VbaEnv) => Value;
1760
+ /** `StrReverse(s)`: a String; Null raises error 94. */
1761
+ declare const strReverse: (v: Value, env?: VbaEnv) => Value;
1762
+ /** `Space(n)` / `Space$`. */
1763
+ declare function space(n: Value, env?: VbaEnv): Value;
1764
+ /** `String(n, char)` / `String$`: a code above 255 is taken Mod 256, as documented. */
1765
+ declare function string(n: Value, ch: Value, env?: VbaEnv): Value;
1766
+ /** VBA's `String$` function: as {@link string}, but a Null argument raises error 94. */
1767
+ declare function stringS(n: Value, ch: Value, env?: VbaEnv): Value;
1768
+ /** `Asc(s)`: the ANSI code of the first character (error 5 for ""). */
1769
+ declare function asc(v: Value, env?: VbaEnv): Value;
1770
+ /** `AscW(s)`: the first UTF-16 code unit, as a signed Integer. */
1771
+ declare function ascW(v: Value, env?: VbaEnv): Value;
1772
+ /** `AscB(s)`: the first byte of the UTF-16LE form. */
1773
+ declare function ascB(v: Value, env?: VbaEnv): Value;
1774
+ /** `Chr(n)` / `Chr$`: an ANSI code 0..255 (error 5 otherwise). */
1775
+ declare function chr(n: Value, env?: VbaEnv): Value;
1776
+ /** `ChrW(n)` / `ChrW$`: a UTF-16 code unit, -32768..65535. */
1777
+ declare function chrW(n: Value, env?: VbaEnv): Value;
1778
+ /** `ChrB(n)`: one byte, which this runtime keeps as the character of that code. */
1779
+ declare function chrB(n: Value, env?: VbaEnv): Value;
1780
+ /**
1781
+ * `InStr([start, ]s1, s2[, compare])`: the 1-based position of `s2` in `s1` from `start`, 0 when
1782
+ * absent, Null when either string is Null. Executors pass `undefined` for an omitted start.
1783
+ */
1784
+ declare function inStr(start: Value | undefined, s1: Value, s2: Value, compare?: Value, optionCompare?: CompareMode, env?: VbaEnv): Value;
1785
+ /** `InStrRev(s1, s2[, start[, compare]])`: searches backwards from `start` (-1 = the end). */
1786
+ declare function inStrRev(s1: Value, s2: Value, start?: Value, compare?: Value, optionCompare?: CompareMode, env?: VbaEnv): Value;
1787
+ /** `StrComp(s1, s2[, compare])`: -1, 0 or 1; Null when either is Null. */
1788
+ declare function strComp(s1: Value, s2: Value, compare?: Value, optionCompare?: CompareMode, env?: VbaEnv): Value;
1789
+ /**
1790
+ * `Replace(expression, find, replace[, start[, count[, compare]]])`: the result starts at
1791
+ * `start`; `count` -1 replaces all. Under text compare a match must cover whole characters
1792
+ * (Replace("straße", "ss", "S", , , 1) is "straSe", but "s" does not split the ß).
1793
+ */
1794
+ declare function replace(expression: Value, find: Value, replacement: Value, start?: Value, count?: Value, compare?: Value, optionCompare?: CompareMode, env?: VbaEnv): Value;
1795
+ /** `Split(expression[, delimiter[, limit[, compare]]])`: a zero-based String array. */
1796
+ declare function split(expression: Value, delimiter?: Value, limit?: Value, compare?: Value, optionCompare?: CompareMode, env?: VbaEnv): Value;
1797
+ /** `Join(sourceArray[, delimiter])`. */
1798
+ declare function join(source: Value, delimiter?: Value, env?: VbaEnv): Value;
1799
+ /** `Filter(sourceArray, match[, include[, compare]])`: a zero-based String array. */
1800
+ declare function filter(source: Value, match: Value, include?: Value, compare?: Value, optionCompare?: CompareMode, env?: VbaEnv): Value;
1801
+ /** `InStrB`: byte positions in the UTF-16LE form (matches start on character boundaries). */
1802
+ declare function inStrB(start: Value | undefined, s1: Value, s2: Value, compare?: Value, optionCompare?: CompareMode, env?: VbaEnv): Value;
1803
+ /** A string's UTF-16LE bytes as a zero-based Byte() array (`b = s` for a Byte array). */
1804
+ declare function strToBytes(s: string, env?: VbaEnv): Value;
1805
+ /** The string a Byte() array holds (`s = b`). */
1806
+ declare function bytesOf(v: Value): string;
1807
+ /**
1808
+ * `StrConv(s, conversion)`: vbUpperCase 1, vbLowerCase 2, vbProperCase 3, vbUnicode 64 (ANSI bytes
1809
+ * to text), vbFromUnicode 128 (text to ANSI bytes, two per character). The East Asian width and
1810
+ * kana conversions (4, 8, 16, 32) raise error 5, as they do outside those locales.
1811
+ */
1812
+ declare function strConv(s: Value, conversion: Value, env?: VbaEnv): Value;
1813
+ /**
1814
+ * VBA's `CBool` function. The C* functions convert as assignment to a variable of the type does
1815
+ * (an object reads through its default member): Null raises error 94, a value of the wrong kind
1816
+ * 13 and a value out of range 6.
1817
+ */
1818
+ declare const cBool: (v: Value, env?: VbaEnv, typed?: boolean) => Value;
1819
+ /** VBA's `CByte` function: rounds half to even; error 6 outside 0 to 255. */
1820
+ declare const cByte: (v: Value, env?: VbaEnv, typed?: boolean) => Value;
1821
+ /** VBA's `CCur` function: rounds to four decimal places; error 6 out of range. */
1822
+ declare const cCur: (v: Value, env?: VbaEnv, typed?: boolean) => Value;
1823
+ /** VBA's `CDate` function: a number or a date or time string as a Date. */
1824
+ declare const cDate: (v: Value, env?: VbaEnv, typed?: boolean) => Value;
1825
+ /** VBA's `CDbl` function. */
1826
+ declare const cDbl: (v: Value, env?: VbaEnv, typed?: boolean) => Value;
1827
+ /** VBA's `CDec` function. */
1828
+ declare const cDec: (v: Value, env?: VbaEnv, typed?: boolean) => Value;
1829
+ /** VBA's `CInt` function: rounds half to even; error 6 outside -32768 to 32767. */
1830
+ declare const cInt: (v: Value, env?: VbaEnv, typed?: boolean) => Value;
1831
+ /** VBA's `CLng` function: rounds half to even; error 6 outside the 32-bit signed range. */
1832
+ declare const cLng: (v: Value, env?: VbaEnv, typed?: boolean) => Value;
1833
+ /** VBA's `CLngLng` function: rounds half to even; error 6 outside the 64-bit signed range. */
1834
+ declare const cLngLng: (v: Value, env?: VbaEnv, typed?: boolean) => Value;
1835
+ /** LongPtr is LongLong on 64-bit Office, the platform this runtime models. */
1836
+ declare const cLngPtr: (v: Value, env?: VbaEnv, typed?: boolean) => Value;
1837
+ /** VBA's `CSng` function. */
1838
+ declare const cSng: (v: Value, env?: VbaEnv, typed?: boolean) => Value;
1839
+ /** VBA's `CStr` function (see {@link toStr} for the text of each type). */
1840
+ declare const cStr: (v: Value, env?: VbaEnv, typed?: boolean) => Value;
1841
+ /** `CVar(v)`: the value itself (an object's default member). */
1842
+ /**
1843
+ * The runtime names of the C* functions that take the trailing `typed` flag. Executors read this
1844
+ * rather than keeping their own list. cVar is not one: it never range-checks.
1845
+ */
1846
+ declare const TYPED_CONVERSIONS: ReadonlySet<string>;
1847
+ declare const cVar: (v: Value) => Value;
1848
+ /** `CVErr(n)`: an Error value, 0..65535. */
1849
+ declare const cVErr: (v: Value, env?: VbaEnv) => Value;
1850
+ /** `Error(n)` / `Error$(n)`: the message of an error number. Without `n` executors pass Err.Number. */
1851
+ declare function error(n: Value, env?: VbaEnv): Value;
1852
+ /** `Hex(n)`: Null gives Null; `Hex$` raises 94. */
1853
+ declare function hex(n: Value, env?: VbaEnv): Value;
1854
+ /** VBA's `Hex$` function: as {@link hex}, but Null raises error 94. */
1855
+ declare function hexS(n: Value, env?: VbaEnv): Value;
1856
+ /**
1857
+ * VBA's `Oct` function: the octal digits of a number, two's complement in the width of its type
1858
+ * (8 bits for Byte, 16 for Integer and Boolean, 32 for Long, 64 for the rest). Null gives Null.
1859
+ */
1860
+ declare function oct(n: Value, env?: VbaEnv): Value;
1861
+ /** VBA's `Oct$` function: as {@link oct}, but Null raises error 94. */
1862
+ declare function octS(n: Value, env?: VbaEnv): Value;
1863
+ /**
1864
+ * `Str(n)`: the number with "." as decimal symbol whatever the locale, and a leading space for
1865
+ * a positive number (the sign's place). Null gives Null.
1866
+ */
1867
+ declare function str(n: Value, env?: VbaEnv): Value;
1868
+ /** VBA's `Str$` function: as {@link str}, but Null raises error 94. */
1869
+ declare function strS(n: Value, env?: VbaEnv): Value;
1870
+ /**
1871
+ * `Val(s)`: the number at the start of a string, ignoring blanks, tabs and line feeds anywhere;
1872
+ * "." is always the decimal symbol; `&H`/`&O` prefixes are read, with an optional type
1873
+ * character. Always a Double.
1874
+ */
1875
+ declare function val(s: Value, env?: VbaEnv): Value;
1876
+ /** `IIf(expr, truePart, falsePart)`: both parts are already evaluated, as in VBA. */
1877
+ declare const iif: (expr: Value, truePart: Value, falsePart: Value, env?: VbaEnv) => Value;
1878
+ /** `Choose(index, ...choices)`: Null when `index` is out of range; it is truncated toward zero. */
1879
+ declare function choose(index: Value, choices: readonly Value[], env?: VbaEnv): Value;
1880
+ /** `Switch(expr1, value1, ...)`: the value of the first true expression, else Null. */
1881
+ declare function switchOf(pairs: readonly Value[], env?: VbaEnv): Value;
1882
+ /** `Partition(number, start, stop, interval)`: the range label, e.g. " 10: 19". */
1883
+ declare function partition(number: Value, start: Value, stop: Value, interval: Value, env?: VbaEnv): Value;
1884
+ /**
1885
+ * `Environ(name)` or `Environ(n)`: the host decides what is visible; by default nothing is, so
1886
+ * every name reads as "" (a program cannot read the machine's environment).
1887
+ */
1888
+ declare function environ(s: VbaSession, expr: Value): Value;
1889
+ /** `vbMethod` (VbCallType): {@link callByName} calls a method. */
1890
+ declare const VB_METHOD = 1;
1891
+ /** `vbGet` (VbCallType): {@link callByName} reads a property. */
1892
+ declare const VB_GET = 2;
1893
+ /** `vbLet` (VbCallType): {@link callByName} assigns a property; the last argument is the value. */
1894
+ declare const VB_LET = 4;
1895
+ /** `vbSet` (VbCallType): {@link callByName} sets an object property; the last argument is it. */
1896
+ declare const VB_SET = 8;
1897
+ /** `CallByName(object, procName, callType, ...args)`. */
1898
+ declare function callByName(object: Value, procName: Value, callType: Value, args: readonly Value[], env?: VbaEnv): MaybePromise<Value>;
1899
+ /**
1900
+ * `MsgBox(prompt[, buttons[, title]])`: the `VbMsgBoxResult`. Without a host UI there is nobody to
1901
+ * answer, so it raises error 445 rather than pretending a button was pressed.
1902
+ */
1903
+ declare function msgBox(s: VbaSession, prompt: Value, buttons?: Value, title?: Value): MaybePromise<Value>;
1904
+ /** `InputBox(prompt[, title[, default]])`: "" when cancelled. */
1905
+ declare function inputBox(s: VbaSession, prompt: Value, title?: Value, defaultText?: Value): MaybePromise<Value>;
1906
+ /** `DoEvents`: yields to the host's event loop; resolves to 0 (no open forms). */
1907
+ declare function doEvents(): Promise<Value>;
1908
+ /** `Command()`: no command line in this environment. */
1909
+ declare const command: () => Value;
1910
+ /** VBA's `Shell` function. Always raises error 445: this environment cannot run it. */
1911
+ declare const shell: () => never;
1912
+ /** VBA's `SendKeys` statement. Always raises error 445: this environment cannot run it. */
1913
+ declare const sendKeys: () => never;
1914
+ /** VBA's `AppActivate` statement. Always raises error 445: this environment cannot run it. */
1915
+ declare const appActivate: () => never;
1916
+ /** External automation servers do not exist here; hosts expose their own objects instead. */
1917
+ declare const createObject: (cls: Value, env?: VbaEnv) => never;
1918
+ /** VBA's `GetObject` function: always error 429, as no external automation servers exist here. */
1919
+ declare const getObject: () => never;
1920
+ /** VBA's `GetSetting` function (the registry): always error 445, as there is no registry here. */
1921
+ declare const getSetting: () => never;
1922
+ /** VBA's `SaveSetting` statement: always error 445, as there is no registry here. */
1923
+ declare const saveSetting: () => never;
1924
+ /** VBA's `DeleteSetting` statement: always error 445, as there is no registry here. */
1925
+ declare const deleteSetting: () => never;
1926
+ /** VBA's `GetAllSettings` function: always error 445, as there is no registry here. */
1927
+ declare const getAllSettings: () => never;
1928
+ /** One piece of a Print list: an expression, a separator, `Spc(n)` or `Tab([n])`. */
1929
+ type PrintPart = {
1930
+ readonly value: Value;
1931
+ } | {
1932
+ readonly sep: ';' | ',';
1933
+ } | {
1934
+ readonly spc: number;
1935
+ } | {
1936
+ readonly tab: number | undefined;
1937
+ };
1938
+ /** How Print writes one value: numbers get a sign space before and a space after. */
1939
+ declare function printValue(v: Value, env?: VbaEnv): string;
1940
+ /**
1941
+ * Lays out a Print list; `newline` is false when the list ends in a separator. A `Tab(n)` to a
1942
+ * column before the current one starts a new line (CR LF in `text`), as VBA does.
1943
+ */
1944
+ declare function printLine(parts: readonly PrintPart[], env?: VbaEnv): {
1945
+ text: string;
1946
+ newline: boolean;
1947
+ };
1948
+ /** `Debug.Print ...`: one sink line per printed line (a trailing separator still ends it here). */
1949
+ declare function debugPrint(s: VbaSession, parts: readonly PrintPart[]): void;
1950
+ /** `Debug.Assert expr`: reports a false assertion to the sink (VBA would break into the debugger). */
1951
+ declare function debugAssert(s: VbaSession, ok: boolean): void;
1952
+ /** VBA's `CurDir` function: always error 445, as there is no file system here. */
1953
+ declare const curDir: () => never;
1954
+ /** VBA's `Dir` function: always error 445, as there is no file system here. */
1955
+ declare const dir: () => never;
1956
+ /** VBA's `EOF` function: always error 445, as there is no file system here. */
1957
+ declare const eof: () => never;
1958
+ /** VBA's `FileAttr` function: always error 445, as there is no file system here. */
1959
+ declare const fileAttr: () => never;
1960
+ /** VBA's `FileDateTime` function: always error 445, as there is no file system here. */
1961
+ declare const fileDateTime: () => never;
1962
+ /** VBA's `FileLen` function: always error 445, as there is no file system here. */
1963
+ declare const fileLen: () => never;
1964
+ /** VBA's `FreeFile` function: always error 445, as there is no file system here. */
1965
+ declare const freeFile: () => never;
1966
+ /** VBA's `Loc` function: always error 445, as there is no file system here. */
1967
+ declare const loc: () => never;
1968
+ /** VBA's `LOF` function: always error 445, as there is no file system here. */
1969
+ declare const lof: () => never;
1970
+ /** VBA's `Seek` function and statement: always error 445, as there is no file system here. */
1971
+ declare const seek: () => never;
1972
+ /** VBA's `GetAttr` function: always error 445, as there is no file system here. */
1973
+ declare const getAttr: () => never;
1974
+ /** VBA's `ChDir` statement: always error 445, as there is no file system here. */
1975
+ declare const chDir: () => never;
1976
+ /** VBA's `ChDrive` statement: always error 445, as there is no file system here. */
1977
+ declare const chDrive: () => never;
1978
+ /** VBA's `FileCopy` statement: always error 445, as there is no file system here. */
1979
+ declare const fileCopy: () => never;
1980
+ /** VBA's `Kill` statement: always error 445, as there is no file system here. */
1981
+ declare const kill: () => never;
1982
+ /** VBA's `MkDir` statement: always error 445, as there is no file system here. */
1983
+ declare const mkDir: () => never;
1984
+ /** VBA's `RmDir` statement: always error 445, as there is no file system here. */
1985
+ declare const rmDir: () => never;
1986
+ /** VBA's `SetAttr` statement: always error 445, as there is no file system here. */
1987
+ declare const setAttr: () => never;
1988
+ /** The `Open` statement (and with it Close, Print #, Write #, Input #, Line Input #, Get, Put). */
1989
+ declare const openFile: () => never;
1990
+ /**
1991
+ * The state behind a test application object from {@link createTestApp}. Tests read and change it
1992
+ * directly to check what VBA code did.
1993
+ */
1994
+ interface TestAppState {
1995
+ /** The `Name` property, also the default member. */
1996
+ name: string;
1997
+ /** The values of the `Cells(row, col)` property, keyed by `"row,col"`. */
1998
+ readonly cells: Map<string, Value>;
1999
+ /** The event hub the `Change` method raises `Changed` through. */
2000
+ readonly events: EventHub;
2001
+ /** Every method call, for assertions. */
2002
+ readonly log: string[];
2003
+ /** The application object itself, the source of its events. */
2004
+ self?: VbaObject;
2005
+ }
2006
+ /**
2007
+ * A fresh test application object and its state: a small in-memory host that exercises the whole
2008
+ * host object protocol (indexed properties, a default member, named arguments, an asynchronous
2009
+ * member, For Each, events and identity). For executor tests.
2010
+ */
2011
+ declare function createTestApp(name?: string): {
2012
+ app: VbaObject;
2013
+ state: TestAppState;
2014
+ };
2015
+ export { cCur as $, DebugSink as $a, year as $i, cmp as $n, jsDateToSerial as $o, pmtCore as $r, chargeWork as $s, rightB as $t, VB_SET as A, curToNumber as Aa, fromLinear as Ai, countsReferences as An, VArr as Ao, toByte as Ar, Cell as As, asc as At, getObject as B, automationMessage as Ba, minute as Bi, hostClass as Bn, VLLng as Bo, mirr as Br, defineUdt as Bs, left as Bt, debugAssert as C, parsedToNumber as Ca, formatCurrency as Ci, ClassFacts as Cn, EMPTY_STR as Co, fixedInit as Cr, noMember as Cs, inStr as Ct, VB_GET as D, CUR_MIN as Da, dateAdd as Di, Counted as Dn, NOTHING as Do, toErr as Dr, resolveDefault as Ds, replace as Dt, printValue as E, CUR_MAX as Ea, formatPercent as Ei, ForEachCursor as En, MISSING_CODE as Eo, toDate as Er, inspected as Es, join as Et, createObject as F, decToString as Fa, dateSerial as Fi, CollectionState as Fn, VDbl as Fo, toLLng as Fr, refOf as Fs, chrW as Ft, partition as G, compareKeys as Ga, time as Gi, and as Gn, VSng as Go, fv as Gr, assignArray as Gs, lenOfType as Gt, iif as H, SearchText as Ha, monthName as Hi, lsetRecord as Hn, VNull as Ho, rate as Hr, Bound as Hs, leftS as Ht, deleteSetting as I, roundEven as Ia, dateValue as Ii, collectionObject as In, VDec as Io, toLng as Ir, tempRef as Is, lCase as It, shell as J, lowerUnit as Ja, timeValue as Ji, imp as Jn, VUdt as Jo, ipmt as Jr, EnvOptions as Js, midB as Jt, saveSetting as K, textCompare as Ka, timeS as Ki, cond as Kn, VStr as Ko, fvCore as Kr, defaultFor as Ks, mid as Kt, doEvents as L, ansiChar as La, day as Li, newCollection as Ln, VEmpty as Lo, toSng as Lr, Udt as Ls, lCaseS as Lt, callByName as M, decFromNumber as Ma, date as Mi, isCountingStore as Mn, VByte as Mo, toDbl as Mr, cell as Ms, ascW as Mt, choose as N, decFromString as Na, dateArg as Ni, release as Nn, VCur as No, toDec as Nr, elemRef as Ns, chr as Nt, VB_LET as O, Dec as Oa, dateDiff as Oi, TerminationQueue as On, NULL as Oo, toStr as Or, resolveDefaultMaybe as Os, split as Ot, command as P, decToNumber as Pa, dateS as Pi, retain as Pn, VDate as Po, toInt as Pr, fieldRef as Ps, chrB as Pt, cByte as Q, upperUnit as Qa, weekdayName as Qi, binaryCompare as Qn, isValue as Qo, pmt as Qr, WorkMeter as Qs, right as Qt, environ as R, ansiCode as Ra, dayOfWeekArg as Ri, ClassDef as Rn, VErr as Ro, cashFlows as Rr, UdtField as Rs, lTrim as Rt, PrintPart as S, parseNum as Sa, formatValue as Si, vtName as Sn, EMPTY as So, fixLen as Sr, is as Ss, filter as St, printLine as T, floatToStr as Ta, formatNumber as Ti, letMember as Tn, MISSING as To, toBool as Tr, MAX_DEFAULT_DEPTH as Ts, inStrRev as Tt, inputBox as U, CollationKey as Ua, now as Ui, like as Un, VNum as Uo, ddb as Ur, VbaArray as Us, len as Ut, getSetting as V, vbaNumberOf as Va, month as Vi, placeArgs as Vn, VLng as Vo, npv as Vr, ArrayOptions as Vs, leftB as Vt, msgBox as W, collationKey as Wa, second as Wi, likeMatch as Wn, VObj as Wo, fin as Wr, arrayOf as Ws, lenB as Wt, TYPED_CONVERSIONS as X, toProper as Xa, timerSeconds as Xi, or as Xn, fromJs as Xo, nper as Xr, VbaEnv as Xs, rTrim as Xt, switchOf as Y, toLower as Ya, timer as Yi, not as Yn, Value as Yo, ipmtCore as Yr, LocalTime as Ys, midS as Yt, cBool as Z, toUpper as Za, weekday as Zi, xor as Zn, given as Zo, num as Zr, WORK_REPORT_MIN as Zs, rTrimS as Zt, mkDir as _, isDateSerial as _a, checkStringLength as _c, sin as _i, qbColor as _n, isTrappable as _o, binType as _r, MaybePromise as _s, strS as _t, curDir as a, dateToStr as aa, makeEnv as ac, randomize as ai, trim as an, createSession as ao, ne as ar, vDbl as as, cLngLng as at, seek as b, splitSerial as ba, copyValue as bc, format as bi, typeNameOf as bn, toVbaError as bo, checkDbl as br, defaultValue as bs, strConv as bt, fileAttr as c, windowYear as ca, makeLocale as cc, atn as ci, uCaseS as cn, onError as co, div as cr, vInt as cs, cStr as ct, fileLen as d, DateParts as da, CompareMode as dc, fix as di, isEmpty as dn, setOnError as do, mul as dr, vObj as ds, error as dt, SYSTEM_FIRST_DAY as ea, currentYear as ec, ppmt as ei, rightS as en, RND_INITIAL_SEED as eo, eq as er, vArr as es, cDate as et, freeFile as f, checkDate as fa, TEXT_COMPARE as fc, int as fi, isError as fn, APP_DEFINED as fo, neg as fr, vSng as fs, hex as ft, lof as g, daysFromCivil as ga, checkArraySize as gc, sgn as gi, isObject as gn, isStandardError as go, cat as gr, EventSink as gs, str as gt, loc as h, dateParts as ha, VbaLimits as hc, roundDouble as hi, isNumeric as hn, errorMessage as ho, bytesToStr as hr, EventHub as hs, octS as ht, chDrive as i, TWO_DIGIT_YEAR_MAX as ia, machineUtcOffset as ic, nextSeed as ii, stringS as in, VbaUi as io, lt as ir, vDate as is, cLng as it, appActivate as j, curToString as ja, linear as ji, escape as jn, VBool as jo, toCur as jr, Ref as js, ascB as jt, VB_METHOD as k, curFromNumber as ka, datePart as ki, counted as kn, TRUE as ko, toBigInt as kr, scalar as ks, strComp as kt, fileCopy as l, DATE_MAX as la, LikePatternCache as lc, cos as li, isArray as ln, onErrorState as lo, idiv as lr, vLLng as ls, cVErr as lt, kill as m, combine as ma, DEFAULT_LIMITS as mc, round as mi, isNull as mn, VbaRuntimeError as mo, sub as mr, vUdt as ms, oct as mt, createTestApp as n, weekOfYear as na, localFields as nc, sln as ni, strReverse as nn, SessionOptions as no, gt as nr, vByte as ns, cDec as nt, dir as o, formatDatePattern as oa, EN_US as oc, rnd as oi, trimS as on, ErrObject as oo, strCompare as or, vDec as os, cLngPtr as ot, getAttr as p, civilFromDays as pa, compareArg as pc, log as pi, isMissing as pn, VbaAbort as po, pow as pr, vStr as ps, hexS as pt, sendKeys as q, textKey as qa, timeSerial as qi, eqv as qn, VT as qo, growth as qr, DEFAULT_ENV as qs, midAssign as qt, chDir as r, weekdayOf as ra, localNow as rc, syd as ri, string as rn, VbaSession as ro, le as rr, vCur as rs, cInt as rt, eof as s, parseDate as sa, VbaLocale as sc, abs as si, uCase as sn, OnErrorState as so, add as sr, vErr as ss, cSng as st, TestAppState as t, SYSTEM_FIRST_WEEK as ta, fixedUtcOffset as tc, pv as ti, space as tn, RndState as to, ge as tr, vBool as ts, cDbl as tt, fileDateTime as u, DATE_MIN as ua, BINARY_COMPARE as uc, exp as ui, isDate as un, resume as uo, mod as ur, vLng as us, cVar as ut, openFile as v, partsToSerial as va, makeLimits as vc, sqr as vi, rgb as vn, notSupported as vo, typing as vr, NamedArgs as vs, val as vt, debugPrint as w, parsesAsDouble as wa, formatDateTime as wi, typeIs as wn, FALSE as wo, letAs as wr, sameObject as ws, inStrB as wt, setAttr as x, ParsedNum as xa, formatS as xi, varType as xn, vbaError as xo, convert as xr, enumerateObject as xs, strToBytes as xt, rmDir as y, serialDay as ya, CopySlots as yc, tan as yi, typeName as yn, raise as yo, boolText as yr, VbaObject as ys, bytesOf as yt, getAllSettings as z, ansiRoundTrip as za, hour as zi, MemberDef as zn, VInt as zo, irr as zr, UdtType as zs, lTrimS as zt };