RosettaCodeData/Task/Call-a-foreign-language-fun.../M2000-Interpreter/call-a-foreign-language-fun...

44 lines
1.3 KiB
Plaintext

Module Checkit {
Global a()
mm=10
Module CallFromVb {
\\ Number get first parameter is numeric else error
Print Number
}
Module Global CallFromVbGlobal {
Read X()
X(0)++
a()=X()
Print "ok"
}
Declare Global vs "MSScriptControl.ScriptControl"
Declare Alfa Module
Print Type$(Alfa) \\ name is CallBack2
With vs, "Language","Vbscript", "AllowUI", true, "SitehWnd", hwnd
Method vs, "Reset"
Method vs, "AddObject", "__global__", Alfa, true
Method vs, "AddCode", {
' This is VBScript code
dim M(9), k ' 0 to 9, so 10 items
Sub main()
CallModule "CallFromVb", 1000
M(0)=1000
CallGlobal "CallFromVbGlobal", M
ExecuteStatement "Print a(0)"
k=me.Eval("a(0)")
CallModule "CallFromVb", k
' use Let to assign a number to variable
ExecuteStatement "let mm=12345"
k=me.Eval("mm")
CallModule "CallFromVb", k
CallModule "CallFromVb", M(0)
End Sub
}
Method vs, "run", "main"
Declare vs nothing
If error then print error$
Print Len(a())
Print a()
}
CheckIt