Macro loacal variables

A forums to allow bugs and problems with Flowcode v7 to be reported and resolved.

Moderator: Benj

Post Reply
User avatar
Alan_37
Posts: 179
Joined: Sun May 01, 2016 8:36 pm
Has thanked: 51 times
Been thanked: 54 times
Contact:

Macro loacal variables

Post by Alan_37 »

Hi

just found this bug
When i set a value to a local variable of a macro, than exit that macro
and back in, the variable get reset to 0 ( I am not initializing the variable ).
This dose not happen to the string variables only to numeric Local Variables .

Is there any way we can fix this please ?

Thanks
Last edited by Alan_37 on Sun Jan 29, 2017 11:13 am, edited 1 time in total.

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Macro loacal variables

Post by LeighM »

As you have found, local variables are only valid within the macro that they are defined, on exit they are lost.
This feature saves RAM space
For persistent variables you need to use global

User avatar
Alan_37
Posts: 179
Joined: Sun May 01, 2016 8:36 pm
Has thanked: 51 times
Been thanked: 54 times
Contact:

Re: Macro loacal variables

Post by Alan_37 »

HI LeighM

OK that makes sens , but now if you fix the string ie : will not save anymore my project will not work
any more , the fcfx file is almost 1MB, so that will be a lot of work to fix from my side .

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Macro loacal variables

Post by LeighM »

Hi,
You cannot rely on the value of local variables, e.g. your string, keeping its value between calls to the macro,
It depends where the compiler has located it and if that RAM space is reused and overwritten.

User avatar
Alan_37
Posts: 179
Joined: Sun May 01, 2016 8:36 pm
Has thanked: 51 times
Been thanked: 54 times
Contact:

Re: Macro loacal variables

Post by Alan_37 »

Hi

I always taught about local variables as a way to organize things , about the non persistent part , must have missed that :?
Well good to know, but have to say that for me are pretty much useless cause i use a lot of macros in macros for example to search and split strings
send rs232 I2c SPI data and so on ..

So as a new feature I think would be nice to have persistent local variables .
Since this is clearly not a bug you may want to move it to new feature request &

Thanks very much for your fast support as always :wink:

Regards

Post Reply