Harikrishnan Venkata Absent Member.
Absent Member.
4159 views

Returning a value from a scripts

Jump to solution

Hi,

we can able to call another scripts from existing script using Workbench.RunScript(). Likewise is it possible to return a value from the scripts which am calling?

0 Likes
1 Solution

Accepted Solutions
AndySchott Absent Member.
Absent Member.

RE: Returning a value from a scripts

Jump to solution

You can return value(s) from a script using Output parameters. You can add an output parameter to a script by following the directions here.

Output parameters can be used in both a visual test and a script. In a script (once the call to Workbench.RunScript() has returned) they are just another item in the array so just access them in the same way (something like args("ouptut_param_name")). In a visual test, when the Execute .NET Script test step is selected, in the Properties window you can select which local variable in the visual test should receive the value of the output parameter when the script has finished executing.

Andy

0 Likes
8 Replies
silknaguser Absent Member.
Absent Member.

RE: Returning a value from a scripts

Jump to solution
0 Likes
silknaguser Absent Member.
Absent Member.

RE: Returning a value from a scripts

Jump to solution

Hi Harikrishnan,

Looks like this code is used to pass parameters to calling script and not the one which returns values from calling script to called script, which you are looking for.

Thanks.

0 Likes
Harikrishnan Venkata Absent Member.
Absent Member.

RE: Returning a value from a scripts

Jump to solution

Yes i already saw that passing parameters but i need to get a value from the script which i called

0 Likes
AndySchott Absent Member.
Absent Member.

RE: Returning a value from a scripts

Jump to solution

You can return value(s) from a script using Output parameters. You can add an output parameter to a script by following the directions here.

Output parameters can be used in both a visual test and a script. In a script (once the call to Workbench.RunScript() has returned) they are just another item in the array so just access them in the same way (something like args("ouptut_param_name")). In a visual test, when the Execute .NET Script test step is selected, in the Properties window you can select which local variable in the visual test should receive the value of the output parameter when the script has finished executing.

Andy

0 Likes
Harikrishnan Venkata Absent Member.
Absent Member.

RE: Returning a value from a scripts

Jump to solution

Thanks for your Kind reply Andy. I will try this

0 Likes
Shyam1 Absent Member.
Absent Member.

RE: Returning a value from a scripts

Jump to solution

Hi Andy,

I did a search on returning parameters/return functions, and I found this thread. Unfortunately though, all the links you provided above are broken. 

What I would like to do is call a .Net function from within another script. I would like the called script to then return a parameter which the calling script can use. I've been successfully using Workbench.runscript() with dictionary parameters... but am not yet familiar with how to return a value from calling the Workbench.runscript() command.

Could you please help 🙂

Cheers

Shyam 

0 Likes
AndySchott Absent Member.
Absent Member.

RE: Returning a value from a scripts

Jump to solution

Shyam,

The link I posted worked for me - I'm not sure why it isn't working for you. It is just a link to a topic in the Workbench help, so you can get to the same place by opening the Workbench help on your machine and searching for the topic "Adding Script Output Parameters".

The Workbench.RunScript() function runs the Main() method of another script. If you would rather directly use classes defined in another script, it might be easier for you to add a reference to that script instead. When you do this, you can use any public classes in that script. There was another thread about this recently, so hopefully that provides enough information to get you started.

Andy

0 Likes
Highlighted
Shyam1 Absent Member.
Absent Member.

RE: Returning a value from a scripts

Jump to solution

Andy,

thanks a lot. That certainly helps.

Cheers

Shyam

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.