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 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.
-
I don't see any documentation on keyword CONST
.. furthermore i have personally seen my CONST variable change..
danger
-
I don't see any documentation on keyword CONST
.. furthermore i have personally seen my CONST variable change..
danger
How and when did this happen? Any attempt I've ever made to do this threw an error. CONSTs could not be re-written either from KRL execution, or even though the VarCor.
Files aren't protected, though, so someone with access could hand-edit the .DAT file containg the CONST declaration.
-
I don't see any documentation on keyword CONST
.. furthermore i have personally seen my CONST variable change..
danger
well... open your eyes...
read pinned topic READ FIRST. it tells you what documentation is essential and where to find it.
when asking for help about programming state your KSS version, post example code of what you 'tried'. words are cheap, show me the proof... CONST are constants. they are not variables. they can be changed if one edits declaration. so show your declaration and steps that allow changing constants without editing their declarations or replacing file.
-
My best guess is that this is where my "RAM cache" hacking workflow bit me in the *ss. I assume that the OS was running an invisible cached version which did not declare CONST
Thank you panic mode for pointing out the correct doc..
I was looking at the "Quickguide ;; KRL-Syntax" before, but i have the right doc now.