Minimalist working example:
Lib.vbs:
Option Explicit Function Twice(n) Twice = n + n End Function
Main.vbs:
Option Explicit Dim goFS : Set goFS = CreateObject("Scripting.FileSystemObject") ExecuteGlobal goFS.OpenTextFile(".\lib.vbs").ReadAll() Dim fpTwice : Set fpTwice = GetRef("Twice") WScript.Echo fpTwice(42)
Output:
cscript main.vbs 84
The error message "... runtime error: invalid call or procedure argument:" GetRef "indicates that the library of functions (import) is to blame.
Update:
I think it can be assumed that the VBScript mechanism supports matching names under / functions / methods with the called code to make alphabetic / direct calls:
n = Twice(11)
and that GetRef ("Double") accesses this table. Therefore, I never expected the call to the indirect / "function pointer" or GetRef () to fail when the literal call was successful.
But according to this and which exists , there are at least four ways to βimportβ libraries / modules into QTP, and since I do not use QTP, I cannot exclude that some (or even all) of these methods do something stupid to cause the behavior you described is incorrect.
source share