Xbasic

a5_run_VBScript Function

Syntax

Result as C = a5_run_VBScript(C VBScriptCode )

Arguments

VBScriptCodeCharacter

The VBScript to execute.

Returns

resultCharacter

Error returned by the VBScript interpreter. result will be an empty string if no error occurred.

Description

The a5_run_VBScript() function runs VBScript code and returns VBScript error messages.

Example 

This code runs a VBScript, which opens a message box with a greeting.

dim vbscript as C
vbscript =<<%a%
dim name 
dim greeting 
name = "Tom" 
greeting = "Hello " + name + vbcrlf + "This is VBScript code inside Alpha Anywhere"
msgbox greeting 
%a%
a5_run_VBScript(vbscript)

The code below has an intentional syntax error (an extra '+' at the end of line 4 of vbscript). In this case, the code does not compile and a5_run_VBScript() returns the error text.

dim vbscript as C
vbscript =<<%a%
dim name 
dim greeting 
name = "Tom" 
greeting = "Hello " + name + vbcrlf + "This is VBScript code inside Alpha Anywhere" +
msgbox greeting
%a% 

result = a5_run_VBScript(vbscript) 
if result <> "" 
    ui_msg_box("script error", result, UI_STOP_SYMBOL)
end if

See Also