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

Check for a file from the edit script

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.

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

Hello,

Use a do loop statement

DO Table: Load * from textfile.txt; sleep 300000;LOOP WHILE Filesize('C:\textfile.txt) > 0;


Hope that helps.

View solution in original post

7 Replies
Not applicable
Author

Can someone please help me out with the script. Thanks.

Miguel_Angel_Baeyens

Hello,

Use a do loop statement

DO Table: Load * from textfile.txt; sleep 300000;LOOP WHILE Filesize('C:\textfile.txt) > 0;


Hope that helps.

tanelry
Partner - Creator II
Partner - Creator II

...

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.

Not applicable
Author

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.

Not applicable
Author

Thanks a lot Tanela and Miquel. Your method works.

Not applicable
Author

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.

tanelry
Partner - Creator II
Partner - Creator II

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
...