Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

Platforms to show: All Mac Windows Linux Cross-Platform

WindowsScriptMBS.AddCode(code as string)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Windows MBS Win Plugin 10.0 No Yes No Yes, Windows only No
Function: 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"
Notes: If you use VBScript, you don't need "dim" keyword for defining variables.

Feedback, Comments & Corrections

WindowsScriptMBS.ClearError
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Windows MBS Win Plugin 10.0 No Yes No Yes, Windows only No
Function: Clears the current error.

Feedback, Comments & Corrections

WindowsScriptMBS.Eval(code as string) as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Windows MBS Win Plugin 10.0 No Yes No Yes, Windows only No
Function: Evaluate an expression within the context of the global module.

Feedback, Comments & Corrections

WindowsScriptMBS.ExecuteStatement(statement as string)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Windows MBS Win Plugin 10.0 No Yes No Yes, Windows only No
Function: 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

Feedback, Comments & Corrections

WindowsScriptMBS.Reset
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Windows MBS Win Plugin 10.0 No Yes No Yes, Windows only No
Function: Reset the scripting engine to a newly created state.

Feedback, Comments & Corrections

WindowsScriptMBS.Run(functionName as string, parameters() as string) as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Windows MBS Win Plugin 10.0 No Yes No Yes, Windows only No
Function: 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

Feedback, Comments & Corrections

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




Links
MBS FileMaker blog