How to update Calendar date if stack is left open overnight?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Mistfall
Posts: 23
Joined: Tue Dec 30, 2008 1:26 pm
Contact:

How to update Calendar date if stack is left open overnight?

Post by Mistfall » Sun Jan 11, 2009 7:11 am

Hello all,

I'm a newbie scripter and have made a calendar stack that will populate fields with the dates of the month and highlight the current date on preOpen stack.

If I rely on the pre-Open stack handlers to draw the calendar, and the user leaves the stack open overnight, they will find that the current date is "wrong" when they look at their calendar again the next morning, and if "overnight" happened on the last day of the month, the month will be "wrong" too.

What is the best way to periodically poll the system date to see if its "stillToday" so the date highlight can be changed or the calendar can be re-drawn if the user leaves the stack open overnight? I'm sure this is a no-brainer to a real programmer, but I have to plead that I'm a biologist and an artist, so I need somebody merciful to throw me a clue!

Thanks!

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Sun Jan 11, 2009 1:23 pm

Dear Mistfall,

Calculate the number of seconds until midnight and put this number into variable mySecs. send a message "checkDate" to your stack in mySecs seconds:

send "checkDate" to me in mySecs seconds

The checkDate handler should call the necessary routines in your stack to update time and date.

Best regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Mistfall
Posts: 23
Joined: Tue Dec 30, 2008 1:26 pm
Contact:

Thank you!

Post by Mistfall » Sun Jan 11, 2009 4:08 pm

Thank you, Mark!

I appreciate the help!

Post Reply