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
Macro loacal variables
Moderator: Benj
- 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
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
This feature saves RAM space
For persistent variables you need to use global
- 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
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 .
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 .
- 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
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.
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.
- 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
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
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