This article will cover the syntax of the ‘Sleep’ regular script statement

This statement is used to pause the execution of a script for a specified period of time.

Statement syntax

TimeThe number of milliseconds to wait. The duration must not be longer than 1 hour. The number can be calculated using an expression.

Example

The script execution checks the last updated date of a QVD file. If it’s before today, i.e. the file is yet to be updated, the sleep function forces the script reload to pause. This is used inside a loop statement until the last updated date on the file is today. Once the condition is met the loop is exited and the script reload proceeds. 

Let Filedate = filetime('[lib://Public:DataFiles/SITE_VISITORS.qvd]');
Do until Filedate >= today()
	sleep 1*1000*60;
	Let Filedate = filetime('[lib://Public:DataFiles/SITE_VISITORS.qvd]');
Loop;

Result

If the file update time is before today, there is a 60 second pause in the script reload after which the file is checked again.