Page 1 of 1
Calling flow with param(s)
Posted: 14 Mar 2015 16:11
by magician
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.
Re: Calling flow with param(s)
Posted: 16 Mar 2015 15:28
by mcyber
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.
Re: Calling flow with param(s)
Posted: 17 Mar 2015 09:34
by mcyber
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.
Re: Calling flow with param(s)
Posted: 20 Mar 2015 09:31
by TheBrain1984
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)?
Re: Calling flow with param(s)
Posted: 20 Mar 2015 22:50
by magician
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'}