Page 1 of 1

Sleep Time

Posted: Sat Oct 08, 2011 2:13 am
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?

Re: Sleep Time

Posted: Sun Oct 09, 2011 6:07 am
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.