Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How Sleep Function works?

Hello Everyone,

   Can anyone explain what is the use of sleep function? I have read that it is used to halt the execution based on the value given in milliseconds. Can anyone explain with an example.

Thanks in advance.

1 Solution

Accepted Solutions
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Its use? You mean you have a solution and now you are looking for a situation to use it in?

Imagine that you have to wait for a file to appear in a folder after launching a job with the EXECUTE; statement. No need to suck up all CPU cycles in a tight loop that keeps checking for this file but doesn't relinquish control (causing the other application to never create the file in the first place). In your FOR loop, check every 10 seconds by inserting a sleep 10000; statement that sleeps for 10 seconds while other processes can do their part of the deal.

Peter

View solution in original post

6 Replies
Peter_Cammaert
Partner - Champion III
Partner - Champion III

See QV Desktop help.

sleep 10000;

will pause script execution for 10 seconds. After that delay, your script will resume.

The sleep parameter can be an expression or a fixed value. But the resulting value can be no larger than 3600000 (i.e. one hour).

Peter

[Edit] corrected spelling erors, grrrr....

MK_QSL
MVP
MVP

The sleep statement pauses script execution for n milliseconds, where n is a positive integer no larger than 3600000

If Date(floor(today()))=Date('14/07/2015')then

     SLEEP 10*1000;

END IF

avinashelite

The sleep statement pauses script execution for n milliseconds, where n is a positive integer no larger than 3600000 (i.e. 1 hour). The value may be an expression.

The syntax is:

sleep n

Examples:

sleep 10000;

sleep t*1000;

Gabriel
Partner - Specialist III
Partner - Specialist III

Hi,

Sleep also help if you have read write lock issue. You can introduce sleep to halt your script for a period.

Also you can check this blog as well Pausing & Stopping QlikView Scripts – Infinity Insight Blog


Peter_Cammaert
Partner - Champion III
Partner - Champion III

Its use? You mean you have a solution and now you are looking for a situation to use it in?

Imagine that you have to wait for a file to appear in a folder after launching a job with the EXECUTE; statement. No need to suck up all CPU cycles in a tight loop that keeps checking for this file but doesn't relinquish control (causing the other application to never create the file in the first place). In your FOR loop, check every 10 seconds by inserting a sleep 10000; statement that sleeps for 10 seconds while other processes can do their part of the deal.

Peter

Anonymous
Not applicable
Author

Thank you Peter, that was really helpful.