Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

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.

Tags (4)
1 Solution

Accepted Solutions
MVP
MVP

Check for a file from the edit script

Hello,

Use a do loop statement

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


Hope that helps.

7 Replies
Not applicable

Check for a file from the edit script

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

MVP
MVP

Check for a file from the edit script

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
Contributor II

Check for a file from the edit script

...

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

Check for a file from the edit script

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

Check for a file from the edit script

Thanks a lot Tanela and Miquel. Your method works.

Not applicable

Check for a file from the edit script

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
Contributor II

Check for a file from the edit script

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

Community Browser