Network Automation Software We are currently migrating this forum
over to our HelpSystems domain. Please
post all new threads in our new
HelpSystems Community Portal.
Post to the HelpSystems Forum
You are not currently logged on. You must be logged on in order to post. Log on
Or Create a new account
AutoMate Discussion
Decrease font size
Increase font size
Topic Title: Task function baby steps
Topic Summary: how do I return a result value?
Created On: 01/28/2015 03:32 PM
Status: Read Only
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
View similar topics View similar topics
View topic in raw text format. Print this topic.
Answer This question was answered by JohnScott, on Monday, February 9, 2015 5:29 PM

Answer:
Thank you, Valentineo. It looks like the Variable - Return action is exactly what I need and assumed should be there. It was merely impossible to find given the inadequate documentation of Task Functions. (I see that you had to refer to the BPA 9 doc, since the Return action is unmentioned in the BPA 8 doc.)
 01/28/2015 03:32 PM
User is offline View Users Profile Print this message

Author Icon
JohnScott
Artisan (200-499)

Posts: 231
Joined: 10/27/2010

I've finally been intrigued enough by the "Make New function" button in the Task Builder that I'm making my first attempt to define a task function, even though I can't find them described anywhere in the v8 online help. I've successfully created a task function that does a 3-step thing I do often, so I can get it from a single Call Task Function step. Great so far!

The Call Task Function action wants a variable to receive a return value from the function. That's a normal, common feature. It's no problem to create another variable and use it for this. But I can't figure out how to assign a value within the function code to pass back out. In most languages you assign a value to the function name, or there is a Return key word. I tried using a Set Variable step to assign my return value to a variable with the same name as my task function. That appeared to send my function into Neverland or an infinite loop.

How is one supposed to assign a value for the task function to return out to the call?

 Category Survey
AutoMate BPA Server 8 version: 8.0.1
Windows version: Windows 2003 R2
 01/28/2015 04:23 PM
User is offline View Users Profile Print this message

Author Icon
Valentineo McGowan
HelpSystems

Posts: 766
Joined: 09/03/2013

Hello John,

Would you be so kind as to attach your task to this forum thread (if not sensitive) OR email it to automate.support@helpsystems.com so we may review?

 Category Survey


-------------------------

Valentineo McGowan | Technical Consultant
AutoMate | Division of HelpSystems
HelpSystems, LLC | T: +1 213.738.6966 | F: +1.213.738.7665
 01/29/2015 11:08 AM
User is offline View Users Profile Print this message

Author Icon
JohnScott
Artisan (200-499)

Posts: 231
Joined: 10/27/2010

Yes, Valentineo, it is attached here. I thought I had explained it clearly enough that you should be able to respond without sample code.

I have since continued on and come up with a second "baby steps" question that is not illustrated in this version of the workflow that I have attached:
How can I include a %var% value in a string value that I pass to a Task Function parameter?

I have just tried:
Call function WriteLogIfDebugLevel(1, "basic message %nDebugLevel%")
and that gives me an error about expecting a )
I tried
Call function WriteLogIfDebugLevel(1, "basic message %%nDebugLevel%%")
and that executed, but passed through the literal string of my var name surrounded by single percent signs.

I don't care whether the %var% is evaluated just as it is being passed to the function or when the receiving parameter variable is used inside the function. I know I could define a new variable for the text I want to pass in, use a Set Variable step to put the evaluated value of the %var% along with the surrounding text into the new var, and then pass the new var as the parameter in my function call (instead of trying to pass in the complex string literal). But having to do a Set Var step before my Call Task Function step is going to undermine my purpose to replace a 3 step sequence with a 1 step function call.

Thanks, John


 Category Survey
AutoMate BPA Server 8 version: 8.0.1
Windows version: Windows 2003 R2



 01/29/2015 05:48 PM
User is offline View Users Profile Print this message

Author Icon
Valentineo McGowan
HelpSystems

Posts: 766
Joined: 09/03/2013

Hello John,

Thank you for the workflow. We will review it and get back with you.

 Category Survey


-------------------------

Valentineo McGowan | Technical Consultant
AutoMate | Division of HelpSystems
HelpSystems, LLC | T: +1 213.738.6966 | F: +1.213.738.7665
 02/02/2015 12:55 PM
User is offline View Users Profile Print this message

Author Icon
Valentineo McGowan
HelpSystems

Posts: 766
Joined: 09/03/2013

Hello John,

Have you attempted using the 'Variable - Return' activity? You may use the 'Return' activity to return a value. The purpose of the Return activity is to exit the current function and return execution to the calling function, at which point, a return value can also be assigned to the caller or it can return the contents of an existing variable, dataset or array (by toggling the Contents of variable/dataset/array option).

NOTE Although a dataset can be selected as one of the return types, it won't be fully supported when it comes to returning values for a task or custom function, at least until a 'Create dataset' action is developed (during a later version).

Return
http://www.networkautomation.c...bles/Return_Action.htm

 Category Survey


-------------------------

Valentineo McGowan | Technical Consultant
AutoMate | Division of HelpSystems
HelpSystems, LLC | T: +1 213.738.6966 | F: +1.213.738.7665
 02/09/2015 05:29 PM
User is offline View Users Profile Print this message

Author Icon
JohnScott
Artisan (200-499)

Posts: 231
Joined: 10/27/2010

Answer Answer
Thank you, Valentineo. It looks like the Variable - Return action is exactly what I need and assumed should be there. It was merely impossible to find given the inadequate documentation of Task Functions. (I see that you had to refer to the BPA 9 doc, since the Return action is unmentioned in the BPA 8 doc.)

 Category Survey
AutoMate BPA Server 8 version: 8.0.1
Windows version: Windows 2003 R2
 02/09/2015 05:51 PM
User is offline View Users Profile Print this message

Author Icon
JohnScott
Artisan (200-499)

Posts: 231
Joined: 10/27/2010

FYI to others who encounter this in the future: when I try to include the Return action in my Task Function, AutoMate fails with error: Expecting ')'

I have successfully gotten a value out of my Task Function by having it set the value of a workflow Shared Variable. It's a method that is frowned on in structured programming, but appears to be the only one available to me at this version of AutoMate.

 Category Survey
AutoMate BPA Server 8 version: 8.0.1
Windows version: Windows 2003 R2
 02/27/2015 05:48 PM
User is offline View Users Profile Print this message

Author Icon
JohnScott
Artisan (200-499)

Posts: 231
Joined: 10/27/2010

I have successfully used the Variable - Return action in v10.1. I have also had success at v10.1 at including variable values in strings that I am passing into my function (see my 01/29/2015 11:08 AM note on this thread).

 Category Survey
AutoMate BPA Server 8 version: 8.0.1
Windows version: Windows 2003 R2
 03/29/2017 08:56 AM
User is offline View Users Profile Print this message

Author Icon
AdamConner
Journeyman (50-99)

Posts: 55
Joined: 02/20/2014

Is a dataset still not a supported return type in v10.x?



 Category Survey
AutoMate BPA Server 8 version:
Windows version:
 03/30/2017 01:28 PM
User is offline View Users Profile Print this message

Author Icon
Justin Aucoin
HelpSystems

Posts: 360
Joined: 02/15/2016

Hi Adam,

The dataset issue was resolved in the 10.1 release of AutoMate and BPA.

 Category Survey
AutoMate BPA Server 8 version:
Windows version:


-------------------------

Justin Aucoin | Support Analyst
AutoMate | Division of HelpSystems
HelpSystems, LLC | T: +1.213.738.1700 | F: +1.213.738.7665
Statistics
18258 users are registered to the AutoMate Discussion forum.
There are currently 0 users logged in.
The most users ever online was 5551 on 01/08/2018 at 11:11 AM.
There are currently 1035 guests browsing this forum, which makes a total of 1035 users using this forum.

FuseTalk Enterprise Edition v4.0 - © 1999-2020 FuseTalk Inc. All rights reserved.

Sitemap Network Automation Software Blog