int setTimerEvent(int nr, int t, int state)
If the function fails to create a timer, the return value is zero, otherwise it is nonzero.
Lets you activate or deactivate one of 10 available timers. When activated, the timer will trigger an (FME_TIMER)? event every t milliseconds until the timer is deactivated again. The possibilities are unlimited with this function. You can use it to e.g. program a stopwatch (see Example below), display a flicker-free animation, perform asynchronous and multi-threaded-like tasks, stop a running calculation after a certain time period.
%ffp ctl(0): STATICTEXT, Size=(140,10) ctl(1): STATICTEXT, Size=(140,10) ctl(3): PUSHBUTTON, Text="Start", Size=(50,15) ctl(5): PUSHBUTTON, Text="Stop", Size=(50,15) OnCtl(n): { int r; static int count0, count1; if (n==0 && e == FME_TIMER) { count0++; setCtlTextv(1, "%d ms", count0*10); } else if (n==1 && e == FME_TIMER) { count1++; setCtlTextv(0, "%d seconds", count1); } else if (n==3 && e == FME_CLICKED){ setCtlText (0,""); setTimerEvent(0,10,1); setTimerEvent(1,1000,1); } else if (n==5 && e == FME_CLICKED){ count0 = count1 = 0; setTimerEvent(0,0,0); setTimerEvent(1,0,0); } return true; }
(FME_TIMER)?
Everyone can add his comments about his experiences with this function here. Tips for using it are welcome, too.