Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I want to check for a file from the edit script and the script should run till the file is present/exist.
I have given the logic below, but I am not able to make it work completely.
"
If Filesize('C:\textfile.txt) >0 then
Load * from textfile.txt
else
sleep 300 //Wait for 5 minutes
and re-execute the above script"
Can someone please help me out with the script. Thanks.
Hello,
Use a do loop statement
DO Table: Load * from textfile.txt; sleep 300000;LOOP WHILE Filesize('C:\textfile.txt) > 0;
Hope that helps.
Can someone please help me out with the script. Thanks.
Hello,
Use a do loop statement
DO Table: Load * from textfile.txt; sleep 300000;LOOP WHILE Filesize('C:\textfile.txt) > 0;
Hope that helps.
...
sub loadfile
If Filesize('C:\textfile.txt) >0 then
Load * from textfile.txt
else
sleep 300000 //Wait for 5 minutes
call loadfile // repeat this sub
end if
end sub
call loadfile
...
This should do the trick. I would also add a counting variable to limit the number of attempts.
Note I revised the sleep time to milliseconds.
Hi Miguel A. Baeyens,
I just got the idea seeing this logic and felt like why it can't be used for auto reload if the user every time wants the up to date data. As qlikview desktop doesn't have auto reload facility I felt this will better option for those who wants to see the latest data.
Hope this logic will not take too much of memory.
Correct me if I am wrong some where.
Thanks a lot Tanela and Miquel. Your method works.
Tanel,
It would be helpful, if you can suggest how to use counter (say limit to 20 counts/try) inside this script and throw an error after that . Thanks.
For simple limit of tries I suggest below (no error thrown), but you can of couse modify it,
like call msgbox or exit script if vLoadAttempt=21.
...
set vLoadAttempt = 1;
sub loadfile
If Filesize('C:\textfile.txt) >0 then
Load * from textfile.txt
else
let vLoadAttempt ='$(vLoadAttempt)'+1;
if vLoadAttempt<=20 then
sleep 300000 //Wait for 5 minutes
call loadfile // repeat this sub
end if
end if
end sub
call loadfile
...