tim [timeS] [function] [flags]



timeS - timer period, seconds. Default: 0. Error if > 2147483.647.

function - name of a user-defined function. Default: this function (the caller).


1 Allow multiple instances of function running simultaneously.
2 QM 2.3.3. One-shot timer. The function will run once. Without this flag, the timer is periodic.



Sets timer that executes function every timeS seconds.


If timeS is 0 or omitted, stops the timer.


If timer for that function is already exists, and timeS is not 0, then changes or just resets its period. Next time the function will run after timeS seconds.


If the timer function is disabled, it does not run, however the timer runs anyway.


The timer function runs in new thread each time. It is not recommended to use tim with small period (<1 s).


Usually it is better to use rep and wait intead of tim. In dialogs procedures and other window procedures, use SetTimer, KillTimer and WM_TIMER instead. See the examples.



To make one-shot timer that will work in all QM versions, use tim 0 (stop timer) in that timer function.

You can see currently active timers in the Running Items list (menu Run -> View Active Items). You can right click an item and stop the timer. Does not show timers started by macros running in separate process.



 Start timer to run function Func every 30 seconds:
tim 30 Func
 Stop it:
tim 0 Func

 Run function Func every 2 seconds:
	wait 2

 Use timer in dialog procedure:
sel message
	SetTimer hDlg 35 1000 0 ;;35 is timer id, 1000 is period in ms
	case WM_TIMER
	sel wParam
		case 35
		KillTimer hDlg wParam
		out "timer 35"