Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
AWS Degraded - You may experience Community slowness, timeouts, or trouble accessing: LATEST HERE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

if scripterror, then jump to next iteration

Hi guys

Any of you have any ideas of how I could resolve this issue in my script. Basically I have loop comparing qvds from different dates. Sometimes it doesn't exist (qvd not found), then I'd like to start the loop from the beginning again. There's probably a quite easy solution to this but I'm not to used to working with loops 😕


let NoOfRows =NoOfRows('DateSpan');
let vConcat = 'OrderComparison:';
For i = 0 to '$(NoOfRows)'-1
let filename = peek('Date',$(i),'DateSpan')';
$(vConcat)
Load
fields
from orders_$(filename).qvd (qvd);
if ScriptError=8 then
next i
end if
;


Comparing orders to previous day's orders to find cancelled orders, but if no file is found I'd like the script to start over with the next iteration, but my solution above combining ScriptError and "if" returns a syntax error.. Apparantly the "next i" part that is incorrect as I can replace i with "exit script" and the script stops if the file isn't found.

let filename = peek('Date',$(i),'DateSpan')'-1;
concatenate(OrderComparison)
Load
fields
from orders_$(filename).qvd (qvd);
let vConcat ='concatenate(OrderComparison)';
next i


I'd appreciate any ideas that could push me in the right direction from here.

Thanks,

// Max

1 Solution

Accepted Solutions
Not applicable
Author

I solved my problem by including the next load statement in the if...end if statement. It's not as pretty as I imagined in my head though 🙂

View solution in original post

3 Replies
Not applicable
Author

Well you've got a few things in there that I don't really understand, but if you put this statement below in the beginning it will ignore errors and keep reloading:

SET ErrorMode=0;

Not applicable
Author

Hi Trent,

I know, it's hard to write it down in an easy way..

I do use errormode=0 already, but the thing is that I do not want to do that second concatenation load since it will mess up the content in the file if the first load goes into error due to missing file.

That is why I want the ScriptError to initiate the next iteration in the "For/next" loop.

Not applicable
Author

I solved my problem by including the next load statement in the if...end if statement. It's not as pretty as I imagined in my head though 🙂