I am using VBScript and I am wondering if there is a way to call the function name stored in a string variable?
Is this my attempt?
a = "b" sub b() msgbox "c" end sub a()
But this always leads to an error
Type A mismatch
Looks like for example this should work:
Dim a a = "Call b()" Eval(a) Sub b ' Do stuff End Sub
Correct answer: use GetRef (), as in:
Function F(p) F = p + p End Function Dim FP : Set FP = GetRef("F") WScript.Echo FP("a") WScript.Echo FP(123)
Output:
aa 246
Dim x Sub b print "xxx"' Do stuff End Sub x = "call b()" Execute(eval("x"))
Source: https://habr.com/ru/post/945581/More articles:How is unit test for form / invalid in Jasmine for AngularJS? - angularjsHow to call a function (with parameters), which is in the library of functions, taking the function name from a variable? - vbscriptHow can I import a function into my QTP test during its launch? - functionGetRef does not work if a function is loaded at runtime using LoadFunctionLibrary - vbscriptIs it possible to call a function whose name is stored in a string in vbscript? - vbscriptHow to decide to use lua_call () or lua_pcall ()? - cefficiently load jquery and javascript files into django templates - performanceDeploying OpenShift - openshiftHow to get Redis Hash Length? - redisandroid - onBackPressed () doesn't work for me - androidAll Articles