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.
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
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....
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
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;
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
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
Thank you Peter, that was really helpful.