Variable already exists

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

Moderator: Benj

Post Reply
jim_g
Posts: 22
Joined: Tue Jan 13, 2015 12:47 pm
Has thanked: 6 times
Been thanked: 8 times

Variable already exists

Post by jim_g »

Hi

I am working up a display management (for a 4D DIABLO screen), part of a larger program, but when compiled it gives the error...

GLCD_Test.c(1338:11): error: variable 'FCR_RETVAL' already exists
GLCD_Test.c success

failure
Completed BoostC compilation, return = 1

C:\Program Files (x86)\Flowcode 6\compilers\pic\boostc\boostc_18F.exe reported error code 1

Now I _did_ have a global variable retval and several local variables .retval in macros. However I have got rid of the local variables and changed the retval to returnvalue and still get the error. I have tried closing down Flow code and re-booting the pc to no avail. The error seems to be associated with the setComponent macro (the latest added).

Any ideas, please?
Regards

Jim
Attachments
GLCD_Test.fcfx
(26.08 KiB) Downloaded 199 times

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:

Re: Variable already exists

Post by Benj »

Hello Jim,

The problem appears to be caused by the variables in the setComponent macro.

You have a byte type return variable but you also have a second variable named Return. If you delete this variable from the macro then the problem should be resolved.
vars.jpg
vars.jpg (26.07 KiB) Viewed 3516 times
I have highlighted which variable to delete in the macros tab of the project explorer.

jim_g
Posts: 22
Joined: Tue Jan 13, 2015 12:47 pm
Has thanked: 6 times
Been thanked: 8 times

Re: Variable already exists

Post by jim_g »

Thanks for that Ben, yes it works.

_But_ ...
a) I already had two other macros with the same local variable Return defined (setDisplayContrast and setDisplayText) and the program compiled and worked without setComponent.
b) If I delete the local Return variables in those macros, I got the error "Unknown or missing local variable: Return

So I confess I have no idea what is going on. What is the correct way to return a value from a macro? I thought that I had to...

* Define the return variable type
* Set the variable Return to the value

... and Bob's your uncle, but it doesn't seem to be that straightforward. Can you explain please (or point me to the help content I can't find!).

Cheers

Jim

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:

Re: Variable already exists

Post by Benj »

Hello Jim,

Here is some info,

http://www.matrixtsl.com/wiki/index.php ... _New_Macro

You should not have to create the Return variables yourself. You can add a return variable type in the edit macro dialogue window which you can get to by double clicking the start icon of the macro you wish to edit.

If you do manually create a variable named Return then this will act as the return variable which may clash with the return type set in the macro dialogue window.

jim_g
Posts: 22
Joined: Tue Jan 13, 2015 12:47 pm
Has thanked: 6 times
Been thanked: 8 times

Re: Variable already exists

Post by jim_g »

Hi Ben

I found the Wiki link, but that does not touch on the special Return variable. If the following change were made...

Return type
Specify the return type, or "No return variable" if the macro does not return a value. Selection of a return type automatically creates a special variable 'Return' that should be used in your code. Subsequent selection of "No return variable" will remove the Return variable.

... this is my understanding (that may well be wrong.

I have followed this method after removing all local Return vatiables, but I now receive the errors...

GLCD_Test.c
Starting preprocessor: "C:\Program Files (x86)\Flowcode 6\compilers\pic\boostc\pp.exe" GLCD_Test.c -i "C:\Program Files (x86)\Flowcode 6\compilers\pic\boostc\include" -d _PIC18F45K22 -la -c2 -o GLCD_Test.pp -v -d _BOOSTC -d _PIC18 -d _CHAR_INDEX

..........................
GLCD_Test.c(1201:2): error: unknown identifier 'FCR_RETVAL'
GLCD_Test.c(1201:2): error: invalid operand 'FCR_RETVAL'
GLCD_Test.c(1201:13): error: failed to generate expression
GLCD_Test.c(1210:2): error: unknown identifier 'FCR_RETVAL'
GLCD_Test.c(1210:2): error: invalid operand 'FCR_RETVAL'
GLCD_Test.c(1210:13): error: failed to generate expression
GLCD_Test.c(1219:2): error: unknown identifier 'FCR_RETVAL'
GLCD_Test.c(1219:2): error: invalid operand 'FCR_RETVAL'
GLCD_Test.c(1219:13): error: failed to generate expression
GLCD_Test.c(1224:10): error: unknown identifier 'FCR_RETVAL'
GLCD_Test.c(1224:10): error: failed to generate expression
GLCD_Test.c(1224:2): error: error in expression
GLCD_Test.c(1224:2): error: failed to generate expression
GLCD_Test.c(1298:2): error: unknown identifier 'FCR_RETVAL'
GLCD_Test.c(1298:2): error: invalid operand 'FCR_RETVAL'
GLCD_Test.c(1298:13): error: failed to generate expression
GLCD_Test.c(1307:2): error: unknown identifier 'FCR_RETVAL'
GLCD_Test.c(1307:2): error: invalid operand 'FCR_RETVAL'
GLCD_Test.c(1307:13): error: failed to generate expression
GLCD_Test.c(1316:2): error: unknown identifier 'FCR_RETVAL'
GLCD_Test.c(1316:2): error: invalid operand 'FCR_RETVAL'
GLCD_Test.c(1316:13): error: failed to generate expression
GLCD_Test.c(1321:10): error: unknown identifier 'FCR_RETVAL'
GLCD_Test.c(1321:10): error: failed to generate expression
GLCD_Test.c(1321:2): error: error in expression
GLCD_Test.c(1321:2): error: failed to generate expression
GLCD_Test.c success

failure
Completed BoostC compilation, return = 1



... these errors are all associated with setDisplayContrast and setDisplayText, the same treatment applied to setComponent does not throw an error. I have re-submitted the program in case I have made a further change by accident.

Regards

Jim
Attachments
GLCD_Test.fcfx
(25.87 KiB) Downloaded 208 times

Post Reply