Parameters not passed to an own written macro

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

Moderators: Benj, Mods

Post Reply
PDeGr
Posts: 12
Joined: Fri Dec 01, 2006 2:56 pm
Location: Belgium

Parameters not passed to an own written macro

Post by PDeGr »

Hi,

I'm using FLOWCODE V3.0.4.29 Pro version.
Are there examples available on how to make macros.

Thanks in advance
Patrick

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Post by Steve »

I don't think we did any examples on this feature. Here's a quick explaination of how it should work:

1) "Macro..New" to create a new macro

2) Enter a name ("AddOne") and a description

3) "Edit Parameters" and add a new BYTE variable called "in"

4) Select "BYTE" as the return type

5) Click "OK" to create the macro

6) Add a single "Calc" icon with the following:

Code: Select all

AddOne.Return = AddOne.in + 1
7) "Edit..Variables" to create 2 new BYTE variables: "x" and "y"

8) In your "main" procedure, add a "Calc" icon with "x=5"

9) Following this, add a "Call Macro" icon. Select your "AddOne" macro, put "x" in as the parameter and "y" in as the return.

10) Step through your program: you should see that y becomes 6 after the "Call Macro" icon has executed.

I hope this helps.

PDeGr
Posts: 12
Joined: Fri Dec 01, 2006 2:56 pm
Location: Belgium

Post by PDeGr »

Hi Steve,

Thanks for the quick reply.

Now it works.

Thanks,
Patrick

PDeGr
Posts: 12
Joined: Fri Dec 01, 2006 2:56 pm
Location: Belgium

Post by PDeGr »

Hi Steve,

It worked fine in simulation.
When I try to compile the program I receive the following error:

macro.c
Starting preprocessor: "C:\Program Files\Matrix Multimedia\Flowcode V3\BoostC\pp.exe" D:\V3pgm\GPS_V1\test\macro.c -i "C:\Program Files\Matrix Multimedia\Flowcode V3\BoostC\include" -d _PIC16F88 -la -c2 -o macro.pp -v -d _BOOSTC -d _PIC16

D:\V3pgm\GPS_V1\test\macro.c(75:10): error: unknown identifier 'FCR_RETVAL'
D:\V3pgm\GPS_V1\test\macro.c(75:2): error: error in expression
D:\V3pgm\GPS_V1\test\macro.c(75:2): error: failed to generate expression
macro.c success

failure

...
Return code = 1

I checked the C program and I can't find a line with the decalration of FCR_RETVAL
I can find FCL_RETURN !!

Regards
Patrick

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Post by Steve »

Please email your file to me and I'll have a look.

PDeGr
Posts: 12
Joined: Fri Dec 01, 2006 2:56 pm
Location: Belgium

Post by PDeGr »

What is your E-mail?
Do you want the .FCF file or the .C file

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Post by Steve »

I should have an email button next to my posts (if not, it's steve [at] matrixmul...... etc) .

Please send me both the fcf and the c files.

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Post by Steve »

Hello Patrick,

There seems to be a bug within Flowcode. I will fix it and release an update within a few weeks.

In the meantime, there is a simple work-around. In the "definitions" box of the "supplementary code" window, put the following line in:

#define FCR_RETVAL FCL_RETURN

I hope this helps.

PDeGr
Posts: 12
Joined: Fri Dec 01, 2006 2:56 pm
Location: Belgium

Post by PDeGr »

I added the C code icon with the code in the macro flow and it works fine.

Thanks
Patrick

Post Reply