WindowsScriptMBS methods

Online Documentation   -   Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchy

New in Version 22.2 22.3 22.4 22.5 23.0 23.1 23.2 23.3 23.4 23.5 24.0 24.1

The list of the   topics,   classes,   interfaces,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

Back to WindowsScriptMBS class.

WindowsScriptMBS.AddCode(code as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Windows MBS Win Plugin 10.0 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Add code to the global module.
Example
dim w as new WindowsScriptMBS

w.Language = "VBScript"

w.AddCode "a = 1" // define some global variables
w.AddCode "b = 2"

If you use VBScript, you don't need "dim" keyword for defining variables.

Some examples using this method:

WindowsScriptMBS.ClearError

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Windows MBS Win Plugin 10.0 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Clears the current error.

WindowsScriptMBS.Eval(code as string) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Windows MBS Win Plugin 10.0 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Evaluate an expression within the context of the global module.

WindowsScriptMBS.ExecuteStatement(statement as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Windows MBS Win Plugin 10.0 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Execute a statement within the context of the global module.
Example
dim w as new WindowsScriptMBS

w.Language = "VBScript"

w.AddCode "a = 1"
w.AddCode "b = 2"

w.AllowUI = true
w.ExecuteStatement "msgbox a+b" // shows 3

w.AllowUI = false
w.ExecuteStatement "msgbox a+b" // shows exception with access denied

Exception e as WindowsScriptErrorExceptionMBS
MsgBox e.message

Some examples using this method:

WindowsScriptMBS.Reset

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Windows MBS Win Plugin 10.0 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Reset the scripting engine to a newly created state.

WindowsScriptMBS.Run(functionName as string, parameters() as string) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Windows MBS Win Plugin 10.0 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Call a procedure defined in the global module.
Example
dim w as new WindowsScriptMBS

// First try VBScript
w.Language = "VBScript"

dim lines(-1) as string

lines.append "Function Test(a,b)"
lines.append "Test = a+b"
lines.append "End Function"

w.AddCode Join(lines, EndOfLine.Windows)

dim p(-1) as string = array("Hello ", "World from VBScript")
dim x as string = w.Run("Test", p)

'MsgBox x

// Second try JScript
w.Language = "JScript"

redim lines(-1)
lines.append "function Test(a,b)"
lines.Append "{"
lines.append "return a+b;"
lines.append "}"

w.AddCode Join(lines, EndOfLine.Windows)

p = array("Hello ", "World from JavaScript")
x = w.Run("Test", p)

MsgBox x

Exception e as WindowsScriptErrorExceptionMBS
MsgBox "Exception: "+e.message

The items on this page are in the following plugins: MBS Win Plugin.


💬 Ask a question or report a problem