Monday, November 08, 2010 at 12:02 AM.

system.verbs.builtins.clock.timerExpired

on timerExpired (processname, ctSecsBetwRuns=60) {
	<<Changes
		<<12/28/01; 6:31:42 PM by DW
			<<Created. Return true if the timer expired, false otherwise.
			<<http://docserver.userland.com/clock/timerExpired
	
	local (adrtable = @system.temp.timers);
	if not defined (adrtable^) {
		new (tabletype, adrtable)};
	local (adrtimer = @adrtable^.[processname]);
	if not defined (adrtimer^) {
		adrtimer^ = clock.now ();
		return (true)}; //run the process
	if (clock.now () - adrtimer^) >= ctSecsBetwRuns {
		adrtimer^ = clock.now ();
		return (true)}; //run the process
	return (false)} //it hasn't expired yet
<<bundle //test code
	<<loop
		<<if timerExpired ("test", 2)
			<<speaker.beep ()



This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.