Hi Rod,
Thanks for the praise. I was noticing that you could improve the sub by
doing the seconds less than 5 and the equate to use the integer division, (mod)
for when the minute interval is 0 then you are on the interval you want, no
remainder.
Have a flag that gets set when the time is spoken and reset when the
seconds are greater than 5 and the minutes integer division (mod) is not 0.
I mention this because there could come a time when the timer function is
off and does not call exactly when you expect it.
The important part of the trip is the minutes division with no remainder.
Or, you could just get rid of the seconds condition since you are using the
timer that actually gets you within that range and just monitor the minutes
value and the division of...
In fact using the timer function that calls the routine at the end of it's
count, only check the minutes and leave out the seconds=0 if condition.
sincerely
Bruce
Sent: Saturday, April 06, 2013 4:56 PM
Subject: Re: Timer in apps stop working
Hi everyone,
Good news! :)
First, thanks for all the concern, advice, and willingness to help. Second,
I think, Bruce, your cuckoo clock is a monument to beauty and app
competence. Cheers to you. Third, Chip, I remembered a comment you made in
your class on event handlers, about the fact that you have to queue speech
and disk access or else you'll run into problems. Well, my clock sub had
this problem, and this is why it was failing to reset. Being fairly new to
writing apps, it's pretty clear that I have a lot to learn. Hey, I was even
thinking, as you see on many e-lists, perhaps we should be given a ranking
when we post to this list. Smile. Well, I'm just teasing a bit, but it is an
idea, although I guess people get to know who the MVP's are, eh? Smile.
I tend to be a bit more hands on then perhaps is good for me, such that I
don't take the time to read good code like yours, Bruce and Chip, but I've
had my chastisement, and I promise I'll do more research before being so
ambitious in the future. Being that as it may, I can't help but enclose my
simple little app for announcing the time, fixed so that it doesn't hang,
and please feel free to comment.
Thanks for everything, good friends,
Rod :)
Here's my code for announcing the time every 15 minutes using the default
synthesizer:
Option Explicit
Dim MyHour, MyMin, MySec
Dim Interval : Interval = 15
StartTimer 1000, "MyTimer"
Sub MyTimer()
MyHour = Hour(Now)
MyMin = Minute(Now)
MySec = Second(Now)
If MySec = 0 Then
If MyMin / Interval = Int(MyMin / Interval) Then 'on the announcement
interval
Queue "SpeakTime"
End If 'on the announcement interval
End If 'MySec = 0
StartTimer 1000, "MyTimer"
End Sub 'MyTimer
Sub SpeakTime()
If MyHour = 0 Then MyHour = 12
If MyHour > 12 Then MyHour = MyHour - 12
If MyMin = 0 Then MyMin = "o'clock"
Speak MyHour & " " & MyMin
End Sub 'SpeakTime()