VBScript modernization

Take VBScript beyond legacy limits without losing compatibility.

AxonASP extends VBScript with VB6-inspired language features, enabling cleaner architecture, stronger contracts, and easier migration from older codebases.

Strong typing Enums and UDTs Events and interfaces Static and GoTo support

Language options now available

Feature What it enables Example impact
Advanced Arrays and Option Base Non-zero lower bounds and module-level default base index. Range-driven indexing patterns for domain data.
Optional parameters and ParamArray Flexible signatures with defaults and variadic argument lists. Reusable utility APIs with fewer overload-style functions.
Explicit ByVal Control pass-by-value behavior to prevent side effects. Safer procedure contracts in critical paths.
Strong typing (As Type) Runtime-enforced variable and parameter type constraints. Earlier detection of mismatch errors and clearer intent.
User-Defined Types (UDT) Structured records with named fields and nested types. Model richer entities in native VBScript syntax.
Enum declarations Named constant sets compiled as constants. Readable state and option handling without magic numbers.
Event Orientation (Event, RaiseEvent, WithEvents) Publisher-subscriber style interaction between class objects. Cleaner decoupling between workflow components.
Interface Polymorphism (Implements) Multi-interface contracts with interface-prefixed member dispatch. Composable object models and stable APIs.
Static variables Procedure-level values that persist across calls in request scope. Counters, memoization, and controlled local state retention.
VB6-style GoTo and labels Absolute flow jumps inside the same procedure. Legacy migration and specialized control flow patterns.
Global console object console.log/info/warn/error/time/dir diagnostics in VBScript. Unified runtime troubleshooting in server and CLI paths.

Example: modern signature with safety

Function BuildLog(ByVal level As String, ByVal msg As String, Optional tag As String = "core", ParamArray labels())
    Dim output, i
    output = "[" & level & "] " & msg & " {" & tag & "}"

    For i = LBound(labels) To UBound(labels)
        output = output & " #" & labels(i)
    Next

    BuildLog = output
End Function

console.log BuildLog("INFO", "runtime started", "boot", "server", "health")

Important constraints

Native file I/O scope

VB6-style native file statements are available in CLI mode. For HTTP and FastCGI environments, use G3FILES for cross-environment file operations.

State boundaries

Static values and in-memory state remain request/session scoped by runtime design; persistent data should be stored in external systems.