Reset Tag Value Each Day
I've created a counter, in order to count the number of times an address is energized each day. I set it up so the count is emailed to me after each day, but I'd like to reset the counter right after that as well. This is the code I currently have, but I can't seem to get the value of my counter to reset, what can I do differently?
SETSYS TAG, "load", "TagName"
SETSYS TAG, "Value", 0
SETSYS TAG, "save"
Above this code I have a GetTime command to initiate the SETSYS TAG instructions. I've played around with the code, and the only error I'll ever get is "[ERROR] Operation failed (28) 44 : SETSYS Tag, "Value", 0". Other than that, no error, but the values don't reset.
Thanks in advance for any guidance!
-
If you're just trying to edit a tag's value, can you try using
TagName@ = 0
instead of the SETSYS commands? As a shortcut, you can retrieve and change tag values with the TagName@ syntax like they are normal Basic variables.
Additionally, instead of getting and checking the time you can use ONDATE commands to schedule actions. If you want to send a report every day at midnight you can do something like:
ONDATE 1, "0 0 * * *", "GOTO SendReport"
END
SendReport:
// report email actions
TagName@ = 0
ENDThe "0 0 * * *" is a cron statement meaning "every day at 00:00". I recommend looking at crontab.guru to help with these statements, as well as RG-0006-01-EN - Programming Reference Guide for more info on our implementation of Basic.
1 -
Thank you for the response, your solution worked for me.
0
Please sign in to leave a comment.
Comments
2 comments