Timer

Syntax

tim [timeS] [function] [flags]

 

Parameters

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

function - name of user-defined function (not macro), which will run every timeS seconds. Default: current function.

flags:

1 allow multiple instances of function running simultaneously.

 

Remarks

Sets timer that periodically executes function. If timeS is 0 or omitted, the timer stops. If timer for that function is already set, and timeS is not 0, then changes the period of the timer. If the timer function is disabled, it does not run, although the associated timer runs anyway.

 

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

 

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

 

Tips

To make one-shot timer, 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.

 

Examples

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

 Run function Func every 2 seconds:
rep
	wait 2
	Func