displayTime freeze

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Sparda
Posts: 11
Joined: Thu Dec 03, 2009 2:02 pm

Re: displayTime freeze

Post by Sparda » Wed Dec 30, 2009 5:08 am

Hi Malte,

Thanks for your response.

I was thinking about using on idle last night. I actually came up with a different solution that actually does what I want it to do but the
downside is the system goes up to 100% CPU usage. More accurately it is "syslogd" that does, so if you want to try this next piece of code
make sure you have activity monitor open while testing and get ready to cancel or set breakpoints. :lol:

***Note check my next post before trying this, I left this post here for reference purposes to show my workflow lol

Code: Select all

on openCard
   displayTime
end openCard

on displayTime
   do "delay 1" as AppleScript
   do "current date" as AppleScript
   put the result into field "fTime"
   send displayTime to me in 0 seconds
end displayTime
If you managed to get "Date & Time" control panel open and change any time/date/zone settings, it will be updated instantly.
Yeah, it's kinda cheating but it works! I'm gonna try and figure out a way to stop the system going crazy.
Maybe I could combine this script in some way with yours Malte.
I even tried utilizing shell by doing "sleep 1" instead of "delay 1" in applescript but I got the same result with "syslogd".

Anyways, I gotta go out for a little while but I will be back soon to try your suggestion Malte.

Thanks again!
Last edited by Sparda on Wed Dec 30, 2009 10:50 am, edited 1 time in total.

Sparda
Posts: 11
Joined: Thu Dec 03, 2009 2:02 pm

Re: displayTime freeze

Post by Sparda » Wed Dec 30, 2009 6:36 am

Wow, I feel like I'm getting much closer now.

This works without the CPU overhead but its still a little crude.

Code: Select all

on openCard
   displayTime
end openCard

on displayTime
   put shell ("sleep 1; date") into field "fTime"
   send displayTime to me
end displayTime
This seems to work nicely but the stack will lock up until I command (.) I can live with this because it will be invisible in the background anyways and will have no user interaction.
The other thing I noticed is the time will skip a second every now and then and I'm assuming this is because the timer did not start precisely on the actual time of 00 seconds in the system.
All I need to do now is figure out a way to synchronize the command somehow via milliseconds to the system time. :shock:

I guess I will keep working on it but still welcome any suggestions. :D

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: displayTime freeze

Post by sturgis » Wed Dec 30, 2009 4:42 pm

Not meaning to hijack this thread, but.. how DO time based applications handle DST changes?

Either 1 hour of a day ceases to exist, or an hour of the day is replayed twice. Since the change happens at 2am, do you disallow any scheduled events between 2 and 3 because the hour won't exist? And on the other end, do you allow scheduling for a 2 hour hour?

Sparda
Posts: 11
Joined: Thu Dec 03, 2009 2:02 pm

Re: displayTime freeze

Post by Sparda » Thu Dec 31, 2009 7:00 am

Hi Sturgis,

I feel like I have to quote bn once again by saying "Welcome to the wonders of time!" rofl. Who would have thunk that making an alarm clock was so complicated.

I had no idea when I first started this that designing something that would trigger something else at a certain time (set by the user) would be so tricky.

Unfortunately it appears runtime revolution is lacking in this area when it comes to dealing with something as simple as the system time.
Although, I could be wrong as I am by no means an expert at using rev, or any other programming language for that matter.

At this point I haven't taken into account DST as the script will only trigger the event when the time set by the user matches the system time.
The basic premise I'm using is (if "SetUserTime" = "SystemTime" then do "Beep") with no exceptions and no anticipation of DST.

I guess there could be a way to tell the event not to run at a certain time if that event had already occurred on that time within the last hour or so but thats where it starts getting tricky. :?

I wish I could offer any more suggestions on the matter but where I live I don't have DST so it never really occurred to me.
I'm sure this problem will rear its ugly head at a later date (no pun intended) but hopefully it won't be an issue.

Maybe someone else has any thoughts on the matter.

PS: I've conceded to using minutes to control my date/time structure and have it updated every 10 seconds or so instead of every second like I planned.
This should be enough to handle any events to be triggered and the user probably won't notice the difference if its 9 seconds passed 12:00pm for example, before it triggers.

Regards,

Post Reply