Calling flow with param(s)

General discussions about Automagic and automation in general

Moderator: Martin

Post Reply
magician
Posts: 4
Joined: 18 Feb 2015 09:59

Calling flow with param(s)

Post by magician » 14 Mar 2015 16:11

I don't like to make 2 action to call flow and pass param. So here is workaround how to pass param to called flow with just single command:

Create action:
Execute flow

as Flow Pattern List put:
{a='value1'; b='value2'; f='FlowA'}

This will call flow named FlowA, inside that flow you can read local variables a and b with values 'value1' and 'value2'

Of course you can use just var a or more variables.

mcyber
Posts: 37
Joined: 08 Nov 2013 14:21

Re: Calling flow with param(s)

Post by mcyber » 16 Mar 2015 15:28

magician wrote:I don't like to make 2 action to call flow and pass param. So here is workaround how to pass param to called flow with just single command:

Create action:
Execute flow

as Flow Pattern List put:
{a='value1'; b='value2'; f='FlowA'}

This will call flow named FlowA, inside that flow you can read local variables a and b with values 'value1' and 'value2'

Of course you can use just var a or more variables.
Not sure if my reply is what you mean, but you can pass and read variables to and from the called flow by flagging the "Return variables to the calling flow" option in the "Execute Flows" action. To enable the option you must flag also "Wait for called flows to finish" option (syncronous execution).
Caller and called flows MUST use the same variable names (local variables).
Only one calling instruction.

mcyber
Posts: 37
Joined: 08 Nov 2013 14:21

Re: Calling flow with param(s)

Post by mcyber » 17 Mar 2015 09:34

mcyber wrote:
magician wrote:I don't like to make 2 action to call flow and pass param. So here is workaround how to pass param to called flow with just single command:

Create action:
Execute flow

as Flow Pattern List put:
{a='value1'; b='value2'; f='FlowA'}

This will call flow named FlowA, inside that flow you can read local variables a and b with values 'value1' and 'value2'

Of course you can use just var a or more variables.
Not sure if my reply is what you mean, but you can pass and read variables to and from the called flow by flagging the "Return variables to the calling flow" option in the "Execute Flows" action. To enable the option you must flag also "Wait for called flows to finish" option (syncronous execution).
Caller and called flows MUST use the same variable names (local variables).
Only one calling instruction.
I'm sorry. Now I understand what you meant. You gave us a hint to avoid two actions. I tried what you suggested and it works perfectly. Looks like only the last assigned variable is managed as a flow name, isn't it?
The only potential problems could be that you may lose some readability and, if you modify the called flow name, Automagic is no longer able to modify the calling instruction accordingly.
A very insight mechanic, anyway.
Thanks for sharing.

User avatar
TheBrain1984
Posts: 137
Joined: 07 Aug 2013 08:17
Location: Germany

Re: Calling flow with param(s)

Post by TheBrain1984 » 20 Mar 2015 09:31

mcyber wrote:
magician wrote:I don't like to make 2 action to call flow and pass param. So here is workaround how to pass param to called flow with just single command:

Create action:
Execute flow

as Flow Pattern List put:
{a='value1'; b='value2'; f='FlowA'}

This will call flow named FlowA, inside that flow you can read local variables a and b with values 'value1' and 'value2'

Of course you can use just var a or more variables.
Not sure if my reply is what you mean, but you can pass and read variables to and from the called flow by flagging the "Return variables to the calling flow" option in the "Execute Flows" action. To enable the option you must flag also "Wait for called flows to finish" option (syncronous execution).
Caller and called flows MUST use the same variable names (local variables).
Only one calling instruction.
Will this also a flow called "value1" (with the
value of value1)?

magician
Posts: 4
Joined: 18 Feb 2015 09:59

Re: Calling flow with param(s)

Post by magician » 20 Mar 2015 22:50

To mcyber:
Yes, exactly! There is no problem to do same thing with 2 actions: first is SCRIPT to set values to variables and second is EXECUTE FLOW,
however in my flow I call one "subflow" about 10 times and I only need to change parameter. So I found this solution how to call flow with param defined directly in EXECUTE FLOW. In my case the readability was better using this "just EXECUTE FLOW" method

To TheBrain1984:
Generally, this:
{a='value1'; b='value2'; f='FlowA'}
sets all 3 values to variables a,b,f
+ finally as a result it "returns" last command value and put this to EXECUTE FLOW command ... see manual for more details.

So this should also work:
{a='value1'; f='FlowA'}

Also ok:
{a='value1'; xxxx='FlowA'}

Also ok (but you just set variable f, and last command has to be name of called flow
{f='FlowA'}

Post Reply