Forum Discussion

kroe761's avatar
kroe761
Contributor
10 years ago
Solved

Call a function as a parameter from another function?

I am maintinaing a lot of legacy test code, and it uses the Runner.CallMethod() function to call methods from other files.  One of the advantages here is that CallMethod uses a string as parameters, ...
  • Ryan_Moran's avatar
    10 years ago

    Functions that reside in other scripts, and that are linked with USEUNIT, effectively become part of the current script.

    You can call them "dynamically" as in your first example like so:

    //USEUNIT My_File
    function test(){
      var functions = ["button_one", "button_two", "button_three"]
      for (var i = 0; i < functions.length; i++){
        var button = My_File[functions[i]]();
        button.Click()
      }
    }