hi everybody
I want use my variables as constant. is it possible declare a variable as constant ans use it after power off ?
constant variable
-
basbasan -
June 19, 2015 at 11:12 AM -
Thread is marked as Resolved.
-
-
Yes, you can declare the variable in any Data Type in Config.dat and assign a value to it like:
DECL INT MY_VARIABLE=10;
Then this value will not change until you change it by yourself or in any program.
Thanks
-
Do you mean "constant," or do you mean "remembered"? Those are two different things.
Any variable declared in a .DAT file, with an initial value, will have its value retained even if the program is reset or the robot is cold-booted.
CodeDECL INT MyCounter ; this won't be remembered DECL INT MyCounter = 1 ; this will be remembered -- the value in the DAT file will be altered every time it changes, and it will be saved if you make an Archive
A constant, on the other hand, cannot be changed -- it's not a variable. Any attempt to change a constant from inside the program, or even from the Variable Monitor, will result in an error. The only way to change a constant is to manually edit the .DAT file.