This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

save the value of a variable in the LM
#1
Hi,

I would like to know how I can save the value of a variable inside the memory of the LM, but that this value will never be erased.
the idea is that I keep the value of a meter variable one month (for example March), the next month (for example April) I create another variable and I keep the value of that month in that variable. Then I take the value of the first variable and I make a difference between the first and the second variable. this to make a comparison of consumption.

I've been looking for a similar example but I have not found anything.

thank you Big Grin
Reply
#2
Hi
Just use trend and counter and all this will be done for you automatically
BR
Reply
#3
Hello,
Thank you, but I do not know if you have an example of how to use the trend and the accountant is honestly new to this
I would really apreciate it
Reply
#4
Hi
How do you want to display the data? If via trend then in there you have ready solution to compare the same trend with different period. If you want the value itself then fetch the data via this. http://openrb.com/docs/trends-new.htm
Reply
#5
Hi.
I have tried with the trends but it does not give me the desired result.
Is there another way to carry out this process without the tendencies?
that is, for example with the storage library, save in a position X of the LM the value of the month and that the next month be stored in a position Y of the LM without affecting the previous value.
With the above, can data be stored for more than 2 years?
thank you
Reply
#6
You can use storage for any kind of data. For example you can store a Lua table there, where each table key is year-month pair:
Code:
key = os.date('%Y-%m') -- YYYY-MM format
value = 123 -- current value

values = storage.get('values', {})
values[ key ] = value
storage.set('values', values)
Reply


Forum Jump: