Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Minimalistic working example:</p> <p><strong>Lib.vbs:</strong></p> <pre><code>Option Explicit Function Twice(n) Twice = n + n End Function </code></pre> <p><strong>Main.vbs:</strong></p> <pre><code>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) </code></pre> <p><strong>Output:</strong></p> <pre><code>cscript main.vbs 84 </code></pre> <p>The error message "... runtime error: Invalid procedure call or argument: 'GetRef'" indicates that the (importing of the) function library is to blame. </p> <p><strong>Update:</strong></p> <p>I <strong>think</strong> that it is plausible to assume that the VBScript engine keeps a table associating sub/function/method names with callable code to be able to do literal/direct calls:</p> <pre><code>n = Twice(11) </code></pre> <p>and that GetRef("Twice") accesses this table. So I would never expect an indirect/'function pointer' call or a GetRef() to fail when the literal invocation succeeds.</p> <p>But according to <a href="https://stackoverflow.com/questions/13300197/how-can-i-import-a-function-into-my-qtp-test-while-its-running">this</a> and <a href="http://www.automationrepository.com/2011/09/associate-function-library-to-qtp-script/" rel="nofollow noreferrer">that</a>, there are at least four ways to 'import' libraries/modules into QTP, and <em>as I don't use QTP</em> I can't rule out, that some (or even all) of these methods do something silly to cause the mis-behaviour you describe.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload