Use return from macro

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

MJU
Posts: 453
Joined: Wed Nov 07, 2007 6:51 pm
Location: Antwerp Belgium
Has thanked: 116 times
Been thanked: 104 times
Contact:

Use return from macro

Postby MJU » Sun Mar 29, 2020 5:53 pm

I've got a macro (lest say: Macro_1), and I've made a local variable .Return
In the macro, I set .Return to 0 if something didn't work, and to 1 when it ran successfully.

From what I've read the .Return should now be used globally to check if the macro ran successfully?

How can I check in another macro if the macro ran OK?
I want to check this returnvalue with a decision macro, should this look like this:

if Macro_1(.return) then?

How can I check in a decision of the macro returned a certain value?

Thanks!!

kersing
Valued Contributor
Valued Contributor
Posts: 1931
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 568 times
Been thanked: 1079 times
Contact:

Re: Use return from macro

Postby kersing » Sun Mar 29, 2020 6:22 pm

The macro call will be the value. So

Code: Select all

if Macro_1() then


In a decision you just enter 'Macro_1()' for the 'if:'.
If your macro requires arguments (say 2) you enter 'Macro_1(1,"second")' or 'Macro_1(.var1, .var2)' if you want to pass the values of local var1 and var2.
These users thanked the author kersing for the post (total 3):
chipfryer27 (Sun Mar 29, 2020 6:50 pm) • MJU (Sun Mar 29, 2020 10:31 pm) • medelec35 (Mon Mar 30, 2020 1:41 am)
Rating: 15%
 
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

MJU
Posts: 453
Joined: Wed Nov 07, 2007 6:51 pm
Location: Antwerp Belgium
Has thanked: 116 times
Been thanked: 104 times
Contact:

Re: Use return from macro

Postby MJU » Sun Mar 29, 2020 11:51 pm

kersing wrote:The macro call will be the value. So

Code: Select all

if Macro_1() then


In a decision you just enter 'Macro_1()' for the 'if:'.
If your macro requires arguments (say 2) you enter 'Macro_1(1,"second")' or 'Macro_1(.var1, .var2)' if you want to pass the values of local var1 and var2.


Thanks for your advice! Again! :-)

I've tried this in a new flowchart and this works..
But when I try this in an existing flowchart I get the error that there are to few arguments.

txt.jpg
txt.jpg (105.01 KiB) Viewed 147 times


The macro it refers to has a .Return which is set (according to it's success or failure), 0 or 1.
But in this case it doesn't work :(
The return value for the macro is set to "BOOL".

kersing
Valued Contributor
Valued Contributor
Posts: 1931
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 568 times
Been thanked: 1079 times
Contact:

Re: Use return from macro

Postby kersing » Mon Mar 30, 2020 7:23 am

Have you checked if the macro checkRX() requires any parameters?
These users thanked the author kersing for the post:
LeighM (Mon Mar 30, 2020 8:42 am)
Rating: 5%
 
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis