#include once "windows.bi" #define UNICODE #include "disphelper/disphelper.bi" ' ************************************************************************** ' RunScript: ' Run a script using the MSScriptControl. Optionally return a result. ' originally by v1ctor, modified for inputbox 2006 by ytwinky, MD ' compiled with fbc 0.17f using FBIde 0.4.6, fpp.exe won't compile this.. ' use option -s gui to avoid the nasty blackbox ' Sub RunScript(byVal szRetIdentifier As LPWSTR, _ byVal pResult As LPVOID, _ byVal szScript As LPWSTR, _ byVal szLanguage As LPWSTR) DISPATCH_OBJ(scrCtl) If (SUCCEEDED(dhCreateObject("MSScriptControl.ScriptControl", NULL, @scrCtl))) Then If (SUCCEEDED(dhPutValue(scrCtl, ".Language = %T", szLanguage))) Then dhPutValue(scrCtl, ".AllowUI = %b", TRUE) dhPutValue(scrCtl, ".UseSafeSubset = %b", FALSE) If(pResult=FALSE) Then dhCallMethod(scrCtl, ".Eval(%T)", szScript) Else dhGetValue(szRetIdentifier, pResult, scrCtl, ".Eval(%T)", szScript) End If End If End If SAFE_RELEASE(scrCtl) End Sub Dim As ZString Ptr tResult dhInitialize(TRUE) dhToggleExceptions(TRUE) '' VBScript sample RunScript("%s", @tResult, !"InputBox(\"This is a good place to input data\" &vbcrlf & \"Hurray, it worx!\",\"ytwinky's InputBox\",\"you may even set a default-value\")", "VBScript") MessageBox(Null, *tResult, "RunScript returned:", 1) dhUninitialize(TRUE)