Wiki Home

Timer Example


Namespace: Wiki
Create a new form: MODIFY FORM TimerTest

Select "timer" from the "form controls" toolbar.

Click on the form somewhere. - this adds a timer to the form.

Right-click on the timer, and select properties.

Set "timer event" to ? "hello world", and "interval" to 1000.

Run the form (^E).

You should see "Hello world" printed on the form once a second. Click the form's X to end it.

Here is a prg version of the same thing, only no form.
loTim = CreateObject( "iTimer" )
accept "enter something" to lcJunk
return

define class iTimer as Timer
    interval = 1000

    function timer
        ? "hello world"
    endfunc

enddefine


The reason for the accept is to give VFP something to do while the timer is going. It keeps loTim from going out of scope and being destroyed. Hitting enter will continue to the return, loTim will be destroyed.

Contributors Carl Karsten
Category Code Samples
( Topic last updated: 2006.06.19 09:44:53 AM )