On Oct 17, 2009, at 11:50 AM, Bob Patin wrote:
> I should mention that it wasn't conceived as something that would
> have a lot of real-world usefulness; I was thinking about the
> various ways to do a clock in FileMaker--web viewer, PHP, script
> trigger--and decided to see how FileMaker would behave when told to
> refresh a container field every quarter-second.
>
> I wrote it last night in front of the TV, so today's the first
> chance I've had to let it run while working in another database, and
> I must say, FileMaker handles all the ontimer events very well.
> Other than some cursor-blink, I don't even notice that the script is
> being triggered.
>
> Anyway, glad you liked it... :)
Ahhh... This reminds of the good old days when I was building games
in FileMaker Pro. They are still up on my site but probably need to be
converted to the newer FMP versions ;-)
Anyways... IMHO, scripting this uses too much background processing.
I would handle it via a CF and a Webviewer (w97xh32):
Start CF (no parameter)
Clock() =
"data:text/html,"&
"<html>¶
<head>¶
<title>JavaScript Clock</title>¶
¶
<style type=\"text/css\">¶
#clock { font-family: Arial, Helvetica, sans-serif; font-size: 0.8em;
color: white; background-color: black; border: 2px solid purple;
padding: 4px; }¶
</style>¶
¶
<script type=\"text/javascript\">¶
<!--¶
¶
function init ( )¶
{¶
timeDisplay = document.createTextNode ( \"\" );¶
document.getElementById(\"clock\").appendChild ( timeDisplay );¶
}¶
¶
function updateClock ( )¶
{¶
var currentTime = new Date ( );¶
¶
var currentHours = currentTime.getHours ( );¶
var currentMinutes = currentTime.getMinutes ( );¶
var currentSeconds = currentTime.getSeconds ( );¶
¶
// Pad the minutes and seconds with leading zeros, if required¶
currentMinutes = ( currentMinutes < 10 ? \"0\" : \"\" ) +
currentMinutes;¶
currentSeconds = ( currentSeconds < 10 ? \"0\" : \"\" ) +
currentSeconds;¶
¶
// Choose either \"AM\" or \"PM\" as appropriate¶
var timeOfDay = ( currentHours < 12 ) ? \"AM\" : \"PM\";¶
¶
// Convert the hours component to 12-hour format if needed¶
currentHours = ( currentHours > 12 ) ? currentHours - 12 :
currentHours;¶
¶
// Convert an hours component of \"0\" to \"12\"¶
currentHours = ( currentHours == 0 ) ? 12 : currentHours;¶
¶
// Compose the string for display¶
var currentTimeString = currentHours + \":\" + currentMinutes + \":
\" + currentSeconds + \" \" + timeOfDay;¶
¶
// Update the time display¶
document.getElementById(\"clock\").firstChild.nodeValue =
currentTimeString;¶
}¶
¶
// -->¶
</script>¶
¶
</head>¶
<body onload=\"updateClock(); setInterval('updateClock()', 1000 )\">¶
¶
<div style=\"clear: both;\"> </div>¶
¶
¶
<div style=\"width: 10em; text-align: left; margin: 0px auto;\">¶
<span id=\"clock\"> </span>¶
</div>¶
¶
</body>¶
</html>"
End CF
Much more efficient. You can modify the CSS to get a different look
and also tweak the code to hide seconds and flash colons.
But you get the idea. Take care ;-)
Don Wieland
D W D a t a C o n c e p t s
~~~~~~~~~~~~~~~~~~~~~~~~~
[hidden email]
Direct Line - (949) 305-2771
Integrated data solutions to fit your business needs.
Need assistance in dialing in your FileMaker solution? Check out our
Developer Support Plan at:
http://www.dwdataconcepts.com/DevSup.htmlAppointment 1.0v9 - Powerful Appointment Scheduling for FileMaker Pro
9 or higher
http://www.appointment10.comFor a quick overview -
http://www.appointment10.com/Appt10_Promo/Overview.html_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au