Cross-platform VB script execution method and system

CN123011313APending Publication Date: 2026-10-30SUPCON TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610916195.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-24
Publication Date
2026-10-30

Smart Images

  • Figure CN123011313A_ABST
    Figure CN123011313A_ABST
Patent Text Reader

Abstract

The application discloses a cross-platform VB script execution method and system, solves the problems of unstable compatibility of a cross-platform VB script execution scheme, low script execution efficiency and high system coupling degree, and comprises the following steps: performing lexical analysis and syntax analysis on a VB script to generate an abstract syntax tree; loading a configuration file during program running, generating a cross-platform script object through a script object name, and binding a cross-platform script object interface with an actual object address during running; switching a script engine type to generate a corresponding script instance; calling script content by a main program, searching and calling in an abstract syntax tree in combination with an object name and an interface name; and calling the main program by the script content and directly calling through the address bound by the script object name and the interface. The VB script can be executed on Windows and Linux operating systems, the existing VB script can run on the Linux system without modifying codes and recompiling, cross-platform VB script execution is realized, the calling efficiency is improved, and the execution efficiency is high.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of industrial automation technology, and in particular to a cross-platform VB script execution method and system. Background Technology

[0002] Engineers draw process flows in configuration software and widely use VB scripts to expand the logic of the screen, including functions such as reading and writing graphic element attributes, event response, and process control.

[0003] However, VB script execution heavily relies on the COM component mechanism and VBScript engine of the Windows operating system. With the advancement of domestic substitution in industrial control systems, configuration software needs to be migrated from the Windows platform to the domestic Linux platform. However, existing cross-platform execution solutions for VB scripts present several drawbacks: Windows VBScript engine-based solutions cannot be deployed across platforms and suffer from COM dependencies, resulting in poor debugging capabilities; Wine-based solutions suffer from significant performance degradation and unstable compatibility; and alternative scripting languages ​​are costly and offer functional differences.

[0004] Patent CN116954711A describes a cross-platform method, system, and script management tool for executing multiple types of scripts. The tool uses a unified script management system to acquire scripts and save them to a first shared library. On one hand, the tool obtains the consumer nodes and script information specified by the user for specific jobs in the job execution process, creating corresponding scheduled tasks for the jobs. Each scheduled task, based on the specified consumer node and script information, periodically triggers the creation of a corresponding job task and stores the created job task in a second shared library. On the other hand, consumer nodes poll the job tasks in the second shared library. When a non-executed job task is identified, it downloads and executes the script specified for that job task from the first shared library. This achieves unified management and execution of multiple types of scripts across platforms, reducing script maintenance costs. While this solution achieves cross-platform script execution, the scripts in this patent are executed at each node in the process, which is different from VB scripts. VB scripts cannot use this solution for cross-platform execution, and it also fails to solve the problems inherent in cross-platform execution of VB scripts. Summary of the Invention

[0005] The purpose of this invention is to solve the problems of unstable compatibility, low script execution efficiency, and high system coupling in existing VB script cross-platform execution schemes. It provides a cross-platform VB script execution method and system that improves calling efficiency, has high execution efficiency, and takes into account both cross-platform compatibility and native Windows performance.

[0006] To achieve the above objectives, the present invention adopts the following technical solution: A cross-platform VB script execution method includes the following steps: S1: Perform lexical and syntactic analysis on the VB script to generate an abstract syntax tree; S2: When the program runs, it loads the configuration file, generates a cross-platform script object by the script object name, and binds the cross-platform script object interface to the actual runtime object address; S3: Switch the script engine type and generate the corresponding script instance; S4: The main program calls the script content, and searches and calls it in the abstract syntax tree by combining the object name and interface name; S5: The script content calls the main program directly through the script object name and the address bound to the interface.

[0007] The cross-platform VB script execution method provided by this invention can execute VB scripts on both Windows and Linux operating systems, and existing VB scripts can run on Linux systems without modifying the code or recompiling, thus realizing cross-platform VB script execution.

[0008] Preferably, S2 includes: loading a configuration file during program runtime, traversing the list of graphical objects in the configuration file; creating a corresponding cross-platform script object for each graphical object based on its type identifier; and binding the function pointer of the cross-platform script object to the actual native object interface pointer at runtime.

[0009] Preferably, S3 includes: defining a script engine type enumeration, and creating a corresponding engine instance during initialization based on the configured script engine type; the engine type includes VBS script engine and cross-platform script engine, VBS engine creates component object model script instance, and cross-platform script engine creates cross-platform script engine instance; when switching script engines, only the script engine type in the configuration item is modified.

[0010] Preferably, S4 includes: when the main program triggers a script execution event, the script execution event is passed to the corresponding pin engine; the script engine combines the function name, finds the corresponding AST node in the generated abstract syntax tree, creates an execution context, and traverses the AST subtree that executes the function.

[0011] Preferably, in step S2, the created cross-platform script object inherits from a unified base class and encapsulates two core virtual interfaces: property reading and property writing.

[0012] Preferably, S1 includes: scanning the VB script source code character by character to identify keywords, identifiers, operators and literals, and generating a lexical unit sequence; performing recursive descent parsing on the lexical unit sequence to generate an abstract syntax tree.

[0013] Preferably, S3 includes dynamically switching the script engine at runtime: during application operation, the engine mode is dynamically switched via API call, the script object of the current script engine is destroyed during the switch, and the script object is recreated using the new script engine.

[0014] Preferably, the abstract syntax tree includes node names and type identifiers, and the node types include expression nodes, statement nodes, and code block nodes.

[0015] A cross-platform VB script execution system, comprising: The upper-level caller is connected to a script engine controller, which is connected to both a cross-platform script engine and a VBS script engine. The script engine controller creates a corresponding script instance based on the configured engine type and passes the script execution event to the corresponding script engine when the main program triggers the script execution event. The cross-platform script engine maintains a global mapping table of all cross-platform script object names and script object member function pointers.

[0016] Preferably, the VBS script engine includes a COM component object connected to an IDispatch interface; the cross-platform script engine includes a lexical analyzer connected to a syntax analyzer, which in turn is connected to an AST execution engine; the syntax analyzer performs multi-level operator precedence parsing and disambiguates assignment statements and function call statements through look-ahead judgment, while converting attribute access into attribute read / write calls.

[0017] Therefore, the present invention has the following beneficial effects: 1. Enable cross-platform execution of VB scripts: Provides a method to execute VB scripts on both Windows and Linux operating systems, allowing existing VB scripts to run on Linux systems without modification, thus protecting users' investments in existing scripts.

[0018] 2. Configurable switching of the current script engine: On the Windows platform, you can switch between the cross-platform script engine and the Windows built-in VBScript engine through configuration. The switching process does not require code modification and recompilation, which takes into account both cross-platform compatibility and Windows native performance.

[0019] 3. Improve script execution efficiency: By using AST caching and execution optimization technology, scripts are avoided from being parsed repeatedly, thus improving script execution efficiency and meeting the requirements of industrial real-time control.

[0020] 4. Reduce system coupling: By replacing the COM component mechanism with a dynamic interface binding mechanism, the script and the host program are decoupled, so that the script engine does not depend on the component technology of a specific operating system. Attached Figure Description

[0021] Figure 1 This is a flowchart of the steps of the cross-platform VB script execution method in this invention.

[0022] Figure 2 This is a schematic diagram of the architecture of the cross-platform VB script execution system in this invention. Detailed Implementation

[0023] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this application will be further described in detail below through embodiments and in conjunction with the accompanying drawings. It should be understood that the specific embodiments described herein are only one preferred embodiment of this application and are only used to explain this application. They do not limit the scope of protection of this application. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.

[0024] The present invention will now be described in further detail with reference to the accompanying drawings and specific embodiments.

[0025] It should be noted that the English names mentioned in the following embodiments have the following meanings: VB (Visual Basic) is a programming language developed by Microsoft and is widely used in the scripting logic of industrial configuration software.

[0026] VBS (Visual Basic Scripting Edition) is the scripting language for VB, a scripting language built into Windows systems.

[0027] An AST (Abstract Syntax Tree) is a tree-like representation of source code generated after lexical and syntactic analysis.

[0028] COM (Component Object Model) is Microsoft's software component interoperability standard, specific to the Windows platform.

[0029] IDispatch (dispatch interface) is a standard interface in COM used for late binding calls.

[0030] The VTable (Virtual Function Table) is a function pointer table used in C++ to implement polymorphism, and it is also used for method dispatch in COM interfaces.

[0031] DLL (Dynamic Link Library) is a shared library format for the Windows platform.

[0032] SO (Shared Object) is a shared library format for the Linux platform.

[0033] Example 1: This embodiment provides a cross-platform VB script execution method, such as... Figure 1 As shown, the operation process is as follows: Step 1, perform lexical and syntactic analysis on the VB script to generate an abstract syntax tree (AST); Step 2, load the configuration file during program runtime, generate a cross-platform script object by the script object name, and bind the cross-platform script object interface to the actual runtime object address; Step 3, switch the script engine type and generate the corresponding script instance; Step 4, the main program calls the script content, searches for and calls it in the abstract syntax tree by combining the object name and interface name; Step 5, the script content calls the main program, directly calling it through the script object name and the address bound to the interface.

[0034] The following examples and specific application scenarios further illustrate the technical solution and effects of the present invention. The following examples are explanations of the present invention, but the present invention is not limited to the following examples.

[0035] In existing technologies, the execution of VB scripts mainly falls into three categories, each with its own technical shortcomings: (1) Script execution based on the Windows VBScript engine.

[0036] This is currently the most common solution. It executes VB scripts using the Windows system's built-in VBScript engine, and the scripts and the host program communicate bidirectionally via the IDispatch interface of the COM component.

[0037] Its working principle is as follows: the host program creates a VBScript engine instance; the host program's object is injected into the script engine's namespace through the IDispatch interface; the script engine parses and executes the VB script code; when the script calls a method of the host object, it performs a late binding call through IDispatch::Invoke; the host program calls the procedure defined in the script through the script engine's IActiveScript interface.

[0038] However, it has the following drawbacks: Platform binding: The VBScript engine is a Windows system component and cannot be used on Linux systems, which makes it impossible to deploy configuration software across platforms; COM dependency: The bidirectional call between the script and the host program depends entirely on the COM IDispatch interface. COM is a component mechanism specific to Windows and cannot be ported to Linux; Debugging difficulty: The VBScript engine is a black box and has limited debugging capabilities.

[0039] (2) Execution of VB scripts based on Wine compatibility layer.

[0040] Wine (Wine Is Not an Emulator) is a compatibility layer for running Windows programs on Linux. Wine allows you to load the Windows VBScript engine DLL onto a Linux system, enabling the execution of VB scripts.

[0041] Its working principle is as follows: Install the Wine runtime environment on the Linux system; load the Windows vbscript.dll through Wine; the host program creates a VBScript engine instance through Wine's COM bridging layer; the script execution process is the same as on the Windows platform, but all COM calls need to go through Wine's intermediate conversion.

[0042] However, it has the following drawbacks: Significant performance loss: The Wine compatibility layer needs to convert Windows API calls to Linux system calls, and COM calls require multiple bridging conversions, resulting in a performance loss of 50%-200%, which cannot meet the requirements of industrial real-time control; Unstable compatibility: Wine's support for COM components is incomplete, and some advanced features of the VBScript engine (such as custom COM object injection, event handling, etc.) may not work properly; Complex deployment: It requires installing the Wine runtime environment and Windows DLL files on the Linux system, increasing the complexity of system deployment and maintenance; License risks: Using Windows DLL files on Linux may involve Microsoft's license issues, posing legal risks.

[0043] (3) Other scripting languages ​​can replace VB script.

[0044] On the Linux platform, cross-platform scripting languages ​​such as Python and Lua are used to replace VB scripts for implementing logical functions.

[0045] Its working principle is as follows: integrate the Python / Lua script engine into the configuration software; manually rewrite the existing VB scripts into Python / Lua scripts; the host program interacts with the scripts through Python C-API or Lua C-API.

[0046] However, it has the following drawbacks: Incompatibility with existing scripts: There are a large number of VB scripts already deployed in industrial sites. Rewriting them to other languages ​​requires a lot of manpower and is prone to introducing errors; Engineer training costs: Field engineers are familiar with VB syntax. Changing the script language requires retraining, which affects the project delivery cycle; Capability differences: Python / Lua and VB have semantic differences (such as Variant types, On Error statements, With statements, etc.), and some VB functions cannot be directly mapped to other languages; Dual version maintenance: Windows platforms still need to use VB scripts, while Linux platforms use other languages. This requires maintaining two sets of script code, increasing maintenance costs and the probability of errors.

[0047] In summary, to address the shortcomings of existing technologies, this embodiment provides a cross-platform VB script execution method that can execute VB scripts on both Windows and Linux operating systems, such as... Figure 1 As shown, the specific steps include: Step 1: The cross-platform script engine performs lexical and syntactic analysis on the VB script and generates an Abstract Syntax Tree (AST).

[0048] After the cross-platform script engine loads the VB script file, the lexical analyzer first scans the script source code character by character to identify lexical units such as keywords, identifiers, operators, and literals, and generates a sequence of lexical units.

[0049] Then, the parser recursively descents the sequence of lexical units to generate an abstract syntax tree (AST).

[0050] The nodes in an abstract syntax tree include a node name and a type identifier. Node types are divided into three main categories: expression nodes, statement nodes, and code block nodes. Expression nodes include literals, unary operators, binary operators, function calls, array access, property access, etc.; statement nodes include variable declarations, assignments, conditional branches, loops, function definitions, selection statements, object reference statements, and dynamically executed statements, etc.

[0051] Step 2: When the program runs, it loads the configuration file, generates a cross-platform script object by the script object name, and binds the cross-platform script object interface to the actual runtime object address.

[0052] Specifically, the following steps are included: Step (2.1): When the program runs, it loads the configuration file and iterates through the list of graphical objects in the configuration file.

[0053] Configuration files are engineering configuration files in industrial automation systems, used to store monitoring screens and equipment parameters, allowing the equipment to operate according to settings. They include elements such as display panels, input controls, and graphical objects; recording the position, size, color, shape, and animation logic of graphical elements in the form of code or structured data.

[0054] Step (2.2): For each graphic object, create a corresponding cross-platform script object based on the type identifier of the graphic terrain. The created cross-platform script object inherits from the unified base class and encapsulates two core virtual interfaces for attribute reading and attribute writing (virtual interface GetObj for attribute reading and virtual interface SetObj for attribute writing).

[0055] After creating the script object, bind the function pointer of the cross-platform script object to the actual native object interface pointer at runtime, so that the call to the cross-platform script object interface can directly call the native object interface through the function pointer.

[0056] The binding method is as follows: Create a cross-platform script object based on the type identifier; Register property mapping: property name → getObj / setObj member function pointer; Inject a pointer to the actual native object at runtime; Store the script object name in the global mapping table as the key; When the script executes: object name + attribute name → look up the global mapping table → function pointer call.

[0057] Step 3: Switch the script engine type by configuring it. The switching process does not require modifying the code or recompiling.

[0058] Define a script engine type enumeration, and create the corresponding engine instance during initialization based on the configured engine type. In this embodiment, the engine types include VBScript script engine and cross-platform script engine.

[0059] Both the VBScript scripting engine and the cross-platform scripting engine implement a unified interface, which includes methods for initialization, object registration, event triggering, and state control. When switching engine types, only the engine type in the configuration settings needs to be modified; no code modification or recompilation is required.

[0060] Specifically, this manifests as follows: Read the configuration and determine the current script engine type based on the configuration. If it is a VBS script engine, create a COM script instance and bind the COM script instance to the IDispatch interface; if it is a cross-platform script engine, create a cross-platform script engine instance.

[0061] The cross-platform scripting engine is primarily used to implement lexical analysis → syntax analysis → abstract grammar book; it is also used to register native callback functions.

[0062] Step 4: The main program calls the script content, combines the object name and interface name to search and call in the Abstract Syntax Tree (AST).

[0063] When the main program triggers script execution (such as in response to a UI interaction event), it passes the event to the corresponding script engine. If it passes the event to a cross-platform script engine, the cross-platform script engine receives the event, searches for the corresponding function definition node in the AST tree using the corresponding function name, and then executes the AST subtree of that function.

[0064] Step 5: The script calls the main program directly through the script object name and the address bound to the interface.

[0065] In VB scripts, reading and writing script object properties is done through the core virtual interfaces (GetObj, SetObj), passing in the object name, properties, and corresponding parameters. Internally, the system finds the corresponding function pointer in the global mapping table (ObjFuncs) based on the passed object name and properties, and then implements the function through the function address of the bound native object.

[0066] The cross-platform VB script execution method provided in this embodiment has the following technical features: (1) Cross-platform script object interface and runtime actual address binding mechanism: By establishing a mapping relationship between the interface name of the script object and the AST node pointer or the host function pointer at runtime, the call to the cross-platform script object interface is to call the real script object, without relying on the COM component mechanism.

[0067] (2) Configurable switching mechanism of script engine under Windows platform: Through a unified script object abstraction interface and script object factory pattern, the cross-platform script engine and the VBScript engine built into Windows can be switched by configuration on the Windows platform without modifying the code or recompiling.

[0068] (3) The main program calls the script method based on the AST tree: The main program combines the script object name and the interface name to find the corresponding AST node in the generated AST tree, creates an execution context and traverses the AST subtree to call the script method.

[0069] (4) Script calls the main program method based on the interface binding address: When the script calls the main program, it directly calls the function of the host program through the script object name and the function pointer address bound to the interface, without going through the COM IDispatch interface, thus reducing the calling overhead.

[0070] Based on the above, the cross-platform VB script execution method provided in this embodiment has the following beneficial effects: (1) Compared with the solution based on the Windows VBScript engine, this invention realizes the execution of VB scripts on Windows and Linux operating systems by building a cross-platform script engine, breaking the dependence of VB scripts on the Windows platform and COM component mechanism. This allows existing VB scripts in industrial configurations to run on Linux systems without modification, protecting users' investments in existing scripts. At the same time, by replacing the COM IDispatch interface with a dynamic interface binding mechanism, the script calls the host program directly through function pointers, reducing the overhead of method lookup and parameter type conversion in IDispatch::Invoke and improving calling efficiency.

[0071] (2) Compared with solutions based on the Wine compatibility layer, this invention does not rely on the Wine compatibility layer, and does not require the installation of the Wine runtime environment and Windows DLL files on the Linux system, thus avoiding the performance loss and compatibility issues of the Wine compatibility layer. The cross-platform script engine of this invention runs directly on the Linux system, with higher execution efficiency, simpler deployment, and no license risks associated with Windows DLLs.

[0072] (3) Compared with the solution of embedding other scripting languages ​​as alternatives, the present invention achieves cross-platform execution of VB scripts without modification, without the need to rewrite existing VB scripts into other languages, saving a lot of manpower and rewriting risks. At the same time, the present invention supports switching back to the VBScript engine that comes with Windows through configuration on the Windows platform, taking into account both cross-platform compatibility and native Windows performance. Users can choose flexibly according to their actual needs without having to maintain two sets of script code.

[0073] Example 2: This embodiment provides a cross-platform VB script execution system for implementing the cross-platform VB script execution method in Embodiment 1.

[0074] Specifically, such as Figure 2 As shown, a cross-platform VB script execution system includes: an upper-level caller, a script engine controller, a VBS script engine, a cross-platform script engine, a cross-platform script object, and native object interface functions. The upper-level caller is connected to the script engine controller, the script engine controller is connected to the VBS script engine and the cross-platform script engine respectively, the cross-platform script engine is connected to the cross-platform script object, and the cross-platform script object is connected to the native object interface functions.

[0075] In this embodiment, the upper-level caller is the configuration screen running system, and the script engine controller is the unified entry point.

[0076] Cross-platform script objects implement property mapping to function pointers.

[0077] The script engine controller manages the defined script engine types and creates corresponding engine instances during initialization based on the configured engine type. When the main program triggers script execution (such as responding to UI interaction events), it passes the event to the corresponding engine through the script engine manager. After receiving the event, the cross-platform script engine searches for the corresponding function definition node in the AST tree using the corresponding function name, and then executes the AST subtree of that function.

[0078] In this embodiment, the script engines include a VBScript script engine and a cross-platform script engine. Upper-level callers of both the VBScript and cross-platform script engines operate through a unified interface and are unaware of the underlying differences. Switching between them only requires modifying the engine type in the configuration settings; no code modification or recompilation is necessary.

[0079] The cross-platform script engine maintains a mapping table (ObjFuncs) between all cross-platform script object names and object member function pointers. After a script object is created, the function pointer of the cross-platform script object is bound to the actual native object interface pointer at runtime, so that the call to the cross-platform script object interface can directly call the native object interface through the function pointer.

[0080] The cross-platform script engine includes a lexical analyzer, a syntax analyzer, an AST execution engine, as well as internal script logic modules and external function call modules. The lexical analyzer is connected to the syntax analyzer, the syntax analyzer is connected to the AST execution engine, and the AST execution engine is connected to the external function call module.

[0081] The lexical analyzer is used to scan VB script source code character by character, identify lexical units, and generate a sequence of lexical units.

[0082] The parser recursively descents the sequence of lexical units to generate an abstract syntax tree. It implements multi-level operator precedence parsing, disambiguates assignment statements from function calls using lookahead checks, and converts attribute accesses into attribute read / write calls.

[0083] The AST execution engine is used for AST traversal execution to implement script method calls.

[0084] The VBScript engine includes COM component objects, which are bound to the IDispatch interface.

[0085] Example 3: This embodiment provides a cross-platform VB script execution method. Based on Embodiment 1, it replaces the script engine type switching method in the third step and the abstract syntax tree (AST) traversal execution method in the fourth step of Embodiment 1.

[0086] Specifically, this embodiment uses a runtime dynamic switching method to switch the script engine type.

[0087] Specifically, this means that during application runtime, the engine mode can be dynamically switched via the management interface or API calls without restarting the application. During the switch, the script object of the current engine is destroyed, and the script object is recreated using the new engine.

[0088] This embodiment uses bytecode compilation to perform the traversal of the Abstract Syntax Tree (AST).

[0089] The specific method involves compiling the AST tree into a custom sequence of bytecode instructions, which is then executed by a bytecode virtual machine. Compared to AST traversal, bytecode execution reduces the overhead of recursive calls and node type checks, resulting in higher execution efficiency.

[0090] The embodiments described above are merely preferred embodiments of the present invention and are not intended to limit the present invention in any way. Other variations and modifications are possible without departing from the technical solutions described in the claims.

Claims

1. A cross-platform VB script execution method, characterized in that, include: S1: Perform lexical and syntactic analysis on the VB script to generate an abstract syntax tree; S2: When the program runs, it loads the configuration file, generates a cross-platform script object by the script object name, and binds the cross-platform script object interface to the actual runtime object address; S3: Switch the script engine type and generate the corresponding script instance; S4: The main program calls the script content, and searches and calls it in the abstract syntax tree by combining the object name and interface name; S5: The script content calls the main program directly through the script object name and the address bound to the interface.

2. The cross-platform VB script execution method according to claim 1, characterized in that, S2 includes: loading the configuration file during program runtime, traversing the list of graphical objects in the configuration file; creating a corresponding cross-platform script object for each graphical object based on its type identifier; and binding the function pointer of the cross-platform script object to the actual native object interface pointer at runtime.

3. A cross-platform VB script execution method according to claim 1 or 2, characterized in that, S3 includes: defining a script engine type enumeration, and creating a corresponding engine instance during initialization based on the configured script engine type; the engine type includes VBS script engine and cross-platform script engine, VBS engine creates component object model script instance, and cross-platform script engine creates cross-platform script engine instance; when switching script engines, only the script engine type in the configuration item is modified.

4. The cross-platform VB script execution method according to claim 1, characterized in that, S4 includes: when the main program triggers a script execution event, it passes the script execution event to the corresponding pin engine; the script engine combines the function name, searches for the corresponding AST node in the generated abstract syntax tree, creates an execution context, and traverses the AST subtree that executes the function.

5. The cross-platform VB script execution method according to claim 2, characterized in that, In S2, the created cross-platform script object inherits from a unified base class and encapsulates two core virtual interfaces: property reading and property writing.

6. The cross-platform VB script execution method according to claim 1, characterized in that, S1 includes: scanning the VB script source code character by character to identify keywords, identifiers, operators and literals, and generating a lexical unit sequence; performing recursive descent parsing on the lexical unit sequence to generate an abstract syntax tree.

7. A cross-platform VB script execution method according to claim 1, 2, 4, 5, or 6, characterized in that, The S3 includes dynamically switching script engines at runtime: during application operation, the engine mode is dynamically switched via API calls. When switching, the script object of the current script engine is destroyed and the script object is recreated using the new script engine.

8. A cross-platform VB script execution method according to claim 1, 4, or 6, characterized in that, The abstract syntax tree includes node names and type identifiers. Node types include expression nodes, statement nodes, and code block nodes.

9. A cross-platform VB script execution system, employing the cross-platform VB script execution method according to any one of claims 1-8, characterized in that, include: The upper-level caller is connected to a script engine controller, which is connected to a cross-platform script engine and a VBS script engine respectively. The script engine controller creates a corresponding script instance according to the configured engine type and passes the script execution event to the corresponding script engine when the main program triggers the script execution event. The cross-platform script engine maintains a global mapping table of all cross-platform script object names and script object member function pointers.

10. A cross-platform VB script execution system according to claim 9, characterized in that, The VBS script engine includes COM component objects connected to the IDispatch interface; the cross-platform script engine includes a lexical analyzer connected to a syntax analyzer, which in turn is connected to an AST execution engine; the syntax analyzer performs multi-level operator precedence parsing and disambiguates assignment statements and function call statements through look-ahead judgment, while converting attribute access into attribute read / write calls.