Page 1 of 1
Macro loacal variables
Posted: Sun Jan 29, 2017 10:53 am
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
Re: Macro loacal variables
Posted: Sun Jan 29, 2017 11:12 am
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
Re: Macro loacal variables
Posted: Sun Jan 29, 2017 11:23 am
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 .
Re: Macro loacal variables
Posted: Sun Jan 29, 2017 11:33 am
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.
Re: Macro loacal variables
Posted: Sun Jan 29, 2017 11:37 am
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
Regards