🖥️ VB CURSE DIFFICULTY: Adept Behavioral

The Interpreter of VBScript

Parsing custom macros using the Microsoft Script Control.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Interpreter
ARCANUM SCHOOL: Divination // Parsing
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// VB PATTERN //
' RitualParser.cls
Private m_sc As Object

Private Sub Class_Initialize()
    On Error Resume Next
    Set m_sc = CreateObject("MSScriptControl.ScriptControl")
    m_sc.Language = "VBScript"
End Sub

Public Function Interpret(expression As String) As String
    On Error Resume Next
    Interpret = m_sc.Eval(expression)
    If Err.Number <> 0 Then
        Interpret = "Syntax Error in the Grimoire"
        Err.Clear
    End If
End Function

Rather than writing a full abstract syntax tree parser in VB6, the Interpreter pattern is often bypassed by summoning the ancient MSScriptControl. Let the OLE gods parse the arcane syntax for you.

Runic Tags: #interpreter #vbscript #scriptcontrol