Forum Discussion
I tried with /without braces, But always giving "function expected" error/reference error. And I did "eval "as well.
var ResultParam = eval(Runner.CallMethod(_impl_verificationManager(),tcInfo,tcData));
Here is my requirement: I have two arrays.In array1 contain functionNames as well.Array2 contains soma required parameters.
I am trying to passing these two arrays as parameters into a function. Which has to call on-demand array[x](Array2) where xth element is function name. Iam trying couple of models , some of them are not able to call,some of them are not able to return values into resultparam.
First parameter of Runner.CallMethod has to be a string of the format unit_name.method_name. So, if you have a script method called "Blah" in unit "MyUnit" with two parameters, you would call
Runner.CallMethod('MyUnit.Blah', 'value1', 'value2')
So, you need to make sure that, whatever that first value is of _impl_verificationManager returns a string in the desired format.
While Runner.CallMethod is noted as obsolete, I'm not sure that it's going away any time soon.
If, however, you are using JavaScript, you could kind of play with the same idea but using classes. Say, for example, you have a class like below. Note that it's best to define the class in a single code unit:
class foo{ constructor(){ this.bar = 'This is my bar'; }
writeBar(){
Log.Message(this.bar);
} } module.exports = foo;
If you want to call the "writeBar" method in some other unit, you can do it something like this.
function runClassMethod(className, methodName){ var localClass = require(className); var localObject = new localClass(); localObject[methodName](); }
function test(){
runClassMethod('foo', 'writeBar');
}
Now, this is just a demonstration of the concept. Obviously, there's more complexity that would need to be applied to do what you want (different parameters, reading values in from spreadsheet, etc), but this is a legitimate replacement for Runner.CallMethod.
Related Content
- 4 years ago
- 10 months ago
- 7 years ago
Recent Discussions
- 2 days ago