Out Argument

Hi,

I am curious of how to use Auguments, especially the Out Argument for LIST variables.

As I know, I have to declare, or initialize a list before using it otherwise there would be an error of “object reference not set to an instance of an object”. What I usually do is to give the default values of the list in Variables or Argument table, e.g. {10, “text1”}.

However, “default value” is not supported for Out Argument. If I initialize the default value in Variable and include the same list in Argument, there would be no expected value in the Out Argument, instead “Null Value” is shown.

May I know how to solve above problem?

Thank you and look forward to you.

You don’t have to supply a default value for your out argument list as it will hold a value from an already initiated list inside your workflow. For example you have a variable listVariable that you have already initiated in the varaiables pane. Then after you have assigned values to listVariable, you will pass it on to the out argument to be used in other workflow by having an assign activity list_Out_Argument = listVariable

Hi @avejr748,

Thank you for the reply.
I have attached a simple example here. Could I trouble you to spot the mistake and rectify it please?
Test.zip (3.6 KB)

Thank you.

@avejr748,

You may notice that there are two Out Arguments in the invoked workflow, Sum and List. The latter is a list and is initiated in both panes of variable and argument (which I am not sure if it is a correct way).

The purpose of the workflow is to find the sum of the List(i), where i=1 to 5 and eventually save the value to both Sum and List(0).

It can be seen that the value of Sum is passed to New_sum in the main, while New_list fails to get values from List.

Hi @GhostBuster here’s your revised workflows. Changes made were to your variable types, you have used arrays instead of list. Additionally, it would be a good practice to have some kind of identifier between ordinary variables and arguments, like having out_variablename or in_variablename for variables to easily identify them.

test_revised.zip (13.8 KB)

Hi @avejr748,

Thanks again for your advice.
Will there be any difference if I do want to use arrays?

Thanks.

From what I know, the difference is that arrays are of a fixed size, which means you cannot add an additional item into it. But in your case where you have a fixed size array then it does not matter much whether you use array or list. I have attached rev2 of your workflow, this time using arrays for your reference.

test_rev2.zip (14.3 KB)

@avejr748,

Thank you very much for your help!

You’re welcome @GhostBuster
Please mark my answer as a solution

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.