Return value from Macro call

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

Moderators: Benj, Mods

Post Reply
User avatar
psf
Posts: 45
Joined: Mon Jun 25, 2007 9:44 pm
Location: Italia
Has thanked: 6 times
Been thanked: 2 times

Return value from Macro call

Post by psf »

Hi, how exactly work this feature?
I call a macro and at last in W (and also in RET_VALUE var) there is the value that I want to save in "A" variable. First time I used to insert a CALC icon where I put A=RE_VALUE.

So I try to write A in the Return Value window of my Macro but don't work; the value of A is always "1".


OTHER QUEST: there is a way to exit from a macro and jump directly at a Flowcode connection point without having "stack" problems?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Post by Benj »

Hello

Firstly you must create or edit your macro so that it has a return type.

I will set this to a byte in this example.

I have named the macro "mac1"

Now you can use a calculation icon to assign a value to the variable mac1.Return

It should be available from the variables list.

Now the value assigned to the return variable should come through to the returned macro call.

To add a connection point simply add this after the macro call. This should work without any problems.

User avatar
psf
Posts: 45
Joined: Mon Jun 25, 2007 9:44 pm
Location: Italia
Has thanked: 6 times
Been thanked: 2 times

Post by psf »

Benj wrote:
To add a connection point simply add this after the macro call. This should work without any problems.
Ok I know the problem is like this example:

macro1:
start
operation1
operation2
......
......
operation24
decision? no----------->jump to main program connection point A
yes
operation25
end

The problem is that this macro is written in asm; and if I write goto _FCC_connectionpoint0001 I suppose that in the stack pointer the previuos opcode address before call macro1 is still present.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Post by Benj »

Hello

It is not wise to jump around from a macro back to a point in the main program. It is better to return a value from the macro and then use this in the main program to decide where to go.

Post Reply