Coding an alarm system

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
ferhan24badshah
Posts: 35
Joined: Sun Feb 02, 2014 12:20 am

Coding an alarm system

Post by ferhan24badshah » Fri Mar 21, 2014 1:33 am

I've coded an alarm system by setting up a button which automatically clicks itself every second to check if the current time is equal to the time set by the user. It works perfectly fine running on my phone except I'm not sure if it takes day light savings into account....I've tested it by moving the time forward on my phone which doesn't affect the button (I can tell because the button also shows the current time at every second in a field ).....but when I move the time backward on my phone, the button stops clicking itself (I can tell because the time in the field stops changing). Is there a better way to code an alarm system which takes day light savings into account as well? Also I'd imagine if the button is clicking itself every second...that would drain the battery..so is there a more better way to code an alarm system? My code looks like this

button "Set"

on mouseUp

put the long time into field "time" (this part of the code is just for me to verify that the button is working properly)

if the long time = "hh:mm:ss am/pm" then
....(sends notification to phone)
end if

send "mouseUp" to button "Set" in 1 second

end mouseUp



Thanks

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Coding an alarm system

Post by Simon » Fri Mar 21, 2014 3:02 am

Hi again ferhan24badshah,
You got me on this
.(sends notification to phone)
because you should (and may be) using "mobileCreateLocalNotification"
But you wouldn't create one of those every second.

Also re the other posting you made.
Your app will shutdown at any random time when it's not in focus.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Post Reply