Forum Discussion
The question does not make sense, Why you want to call two functions in single line?
Yes, I know but it is req from the client. In test complete we can import functions from unit 1 to unit 2 and call them , that's easy, Client not statisfied with that. Can we use Onclick event to call two fucntions ? for example in javascript.
- AlexKaras6 years agoChampion Level 3
Hi,
Still not sure about actual problem and use case that caused it. Can you describe it with more details?
The simple and obvious solution is to create a third function that will call required two ones and call this function. Technically it will be one-liner.
But something tells me that this is not what you are looking for.
(If you are looking for concurrent code execution (like calling different functions from two different threads), then this is not possible in scripting languages.)- Daniellovesmith6 years agoContributor
Got the solution from Smartbear.
In JavaScript, store your functions in the arrays and call them using key values. Here is the example code:
function f(){
let dyn_functions = [];
dyn_functions['Test1'] = function (arg1, arg2) {
return arg1 - arg2
};
dyn_functions['Test2'] = function (arg1, arg2) {
return arg1 + arg2
};
// calling one of the functions
let result = dyn_functions['Test1'](1, 2);
// this works as well
let result2 = dyn_functions.Test2(1, 2);
Log.Message("")
}Thanks everyone for looking into the issue.
- AlexKaras6 years agoChampion Level 3
Still did not get use case and thus the actual need and the principal difference of the suggested solution from just calling two functions from the third one (the wrapper)...
But the above is irrelevant as long as you are satisfied with the suggested approach.
Related Content
Recent Discussions
- 2 days agovladd1