summaryrefslogtreecommitdiffstats
path: root/doc/scriptexamples/timer1.kvs
blob: b123c6b7bcae10f4fcc2f606e4d3318ba3ee7829 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# This is a simple example of using the builtin object timer
# capabilities.

# we create a new object
%bomb = $new(object,0,myobject)

# implement its timerEvent
privateimpl(%bomb,timerEvent)
{
	if($$->%secsToGo > 0)
	{
		echo "Countdown: $$->%secsToGo"
		$$->%secsToGo--;
	} else {
		echo "Boom!"
		delete $this
	}
}

# and trigger it
echo "Countdown: 10 seconds to go"
%bomb->%secsToGo = 9
%bomb->$startTimer(1000)

# now just have to wait...