Sleep Time

General HouseBot discussion. Any issues that don't fit into any of the other topics belong here.
Post Reply
kolesar007
Member
Posts: 14
Joined: Sun Dec 02, 2007 11:15 am

Sleep Time

Post by kolesar007 »

VB sripts section is locked so I post here.
I use sleep timer for same timed task and I want to use one of this for two task becouse of optimization.
On startup I want to read value "Sleep Time" to remember current state, then write some different value in it, run somtimes and then write those stored number into it.
Problem is when i I read GetPropertyValue ("TimerReload.Sleep Time") I got just two digit value 1:4 for example when first digit is days, hour or minutes which value is first greater then 0 and second is seconds velue.

When I try write in this form it works:
SetPropertyValue "TimerReload.Sleep Time", "Days=0, Hours=00, Minutes=00, Seconds=05, MilliSeconds=0"
but I want to load on previus state so I must get this kind of data from read?
Richard Naninck
HouseBot Guru Extraordinaire
Posts: 1121
Joined: Tue Sep 28, 2004 7:49 am
Location: The Netherlands

Re: Sleep Time

Post by Richard Naninck »

The only thing to do this is by building your own correct Property Value through parsing what you get from the GetPropertyValue.

So if you get 1:00:02:03.1 from strSleepTime = GetPropertyValue("TimerReload.Sleep Time") Then build a new PropertyValue by parsing the data you got like:

arrData = Split(strSleepTime, ":")
intDays = arrData(0)
intHours = arrData(1)
intMinutes = arrData(2)
arrSeconds = Split(arrData(3), ".")
intSeconds = arrSeconds(0)

'Don't care about MiliSeconds I hope or else you need an extra If to check the UBound of strSeconds

Now you have your data to build yourself a valid PropertyValue:

SetPropertyValue "TimerReload.Sleep Time", "Days=" & intDays & ", Hours=" & intHours & ", Minutes=" & intMinutes & ", Seconds=" & intSeconds

All of the above is untested but should work. It should give you an idea. Furthermore you don't need to include the MiliSeconds part if it is zero and you need to have some clou about what you are going to expect from the GetPropertyValue because only non zero values will be given. So if Days=0 then you won't get Days and your returned value looks a bit different. But I guess you can figure that one out by doing some tests. The main thing is that you have to build your own valid PropertyValue for the to work.
Post Reply