Article Preview
Buy Now
| Print: | |
| PDF: |
Beginner's Corner
Alarming Techniques
Using a Timer to create an Alarm Clock class
Issue: 5.4 (May/June 2007)
Author: Marc Zeedar
Article Description: No description available.
Article Length (in bytes): 31,843
Starting Page Number: 34
RBD Number: 5413
Resource File(s):
5413.zip Updated: Friday, May 18, 2007 at 10:49 AM
Related Link(s): None
Known Limitations: None
Excerpt of article text...
Recently I assisted a REALbasic user on the NUG who was struggling to get a simple Alarm Clock program working. Via our correspondence, I realized he was not understanding some of the fundamentals involving the Timer control, so I decided that would be an excellent topic for today's lesson.
On the surface, a Timer seems like a simple control. It does not have many features. It's invisible, so there's no user interface to worry about, and only a couple properties to set. However, it is this very simplicity which can make the control confusing.
Timer Basics
If you're not familiar with the Timer, it's a really handy control. A Timer simply activates every x milliseconds. It can execute whatever code you'd like at that time, from simply checking to see if a particular key has been pressed or a state entered to handling some animation or updating a display. You can create multiple Timers that trigger at different times, if you like.
For beginning REALbasic programmers who are used to traditional sequential programming, event-based programming can be frustrating and confusing, and one of the key reasons for that is that since the user's in control, how do you handle periodic, repetitive tasks? Say you want to update a clock display. A typical REALbasic program only executes code in response to the user's actions, so how would you update the clock? Or take a game: many games rely on a sort of heartbeat, where things happen based on the current time. How do you do that in an event-based program?
...End of Excerpt. Please purchase the magazine to read the full article.
Article copyrighted by REALbasic Developer magazine. All rights reserved.
|








