Clock
Copyright  1993, 1994 by Apple Computer, Inc.  All rights reserved.
by Maurice Sharp

Welcome to Wiggy Clock!

This is a very simple bit of code that shows a couple of things
	idle scripts
	time formats and fun

All the work is done in the protoStaticText item, so lets take a tour....

viewBounds

Set them this way to get nice centered justification, also set the height
dynamically in the viewSetupFormScript()

viewSetupDoneScript()

This is where I set up the idle task. First I setup an initial string (might as
well use viewIdleScript(), otherwise I would just end up duplicating code).

Then call the SetupIdle() call and pass it 1000 milliseconds (1 second). This
says, call my viewIdleScript() in 1 second. (NOTE: pass 0 or NIL to disable the
idle behavior).

viewIdleScript

First, a constant used to specify a time specification (really). This is used by
the TimeStr() function (and also by ShortDateStr() and LongDateStr()). Take a
look at those manuals, chapter 18...

First I figure out the current seconds. The Time() function returns minutes
since January 1 1904, TimeInSeconds() returns seconds since January 1 1993 (note
the different years). So I do a bit of trickery to get the current seconds (well
not much trickery). And remember, the string needs to always have 2 digits, so
pad it if needed.

Next, set my text value, simple huh? This SetValue call makes sure the text is
updated on the display.

Finally, return 1000 milliseconds so that the script will get called the next
second. Is this easy or what...

DANGER WILL ROBINSON... Remember that idle scripts are potential battery sinks.
Just leave that sucker going and watch the battery meter drop... I should really
be doing a minute (60000 millisecond) update to be nice. Then I could just use
Time(), gosh Batman, it could have been easier, but then this would not be DTS,
and I would not be....

Dr. What
