Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
datanibbler
Champion
Champion

Trouble with an IF THEN clause

Hi,

I'm still having trouble with an app I have to check the presence of files (and their number and name) in a certain directory - that's just to make sure the correct nr. of files with the correct names is there because some other apps depend on that, and to send email_alerts to the responsibles if that is not the case.

One part of the code in this app is conditionalized to only run on Fridays - it checks a specific subdirectory where the files for the next week should always be stored, and it isn't reasonable to expect those files to be there before Friday. So I want the check to only run on a Friday.

What happened today - and the two last weeks - was that the code did not run on Fridays. When I go through it in the Debugger, it jumps straight to the ENDIF (at the very end of the tab), so the code inbetween is seemingly not being executed.

I can post the code here (I'll attach it) though it won't work for you, there is a number of filepath_variables involved.

Can anybody help me with that?

Thanks a lot!

Best regards,

DataNibbler

15 Replies
datanibbler
Champion
Champion
Author

Hi Joe and Marcus,

the other issue is solved, so here I go again.

@ Joe

Today(0) would of course return wrong results if the code started before midnight, but the script starts at 6am - I have none running for 6hrs, that would be quite strange for QlikView is really fast. i have one running for 20min, but that is the longest.

I have also had the thought of introducing TRACE statements - and I now have a variable automatically highlighting the end of one script_tab and the beginning of the next, so I can also use that.

Thanks a lot!

Best regards,

DataNibbler

datanibbler
Champion
Champion
Author

Okay - those TRACE commands clearly show me that the code for Fridays is indeed skipped.

I will try changing that to Monday to see if it runs then.

The alert on the GUI is set to fire only on Fridays separately - otherwise it would fire every day because when the code is not run, the field that alert is set to check doesn't exist.

Best regards,

DataNibbler

P.S.: Now I've changed it to Monday and as expected, the code is then run, both locally and on the server. I've also inserted a TRACE statement to show me what the weekday_check returned.

I'll change it back now and wait for Friday ...

Not applicable

Change it to Tues so we can see what the trace statements show during a proper over night run sooner maybe? Saves waiting until Fri.

If it just worked fine on the server and locally today but then overnight during the 6am load doesn't work, that does point more to some timing issue.

datanibbler
Champion
Champion
Author

Hi Joe,

the same thing just happened again - the code was not executed this morning at 6am and the alarm fired because

the field it was set to look for didn't exist.

I just have an idea. Maybe someone can confirm that:

=> In the log, the TRACE command I built in just before that (it also uses >> Weekday(Today(0)) << )

      read "Thu"

=> Could it be, though the script doesn't say so, that Today(0), like Now(0) does not react right during the
      script_reloading process, but only the next time round?

      => In that case, the code, when reloaded at 6am on Friday, would use the result of Today() from the last
            script_run, which was on Thursday, and that particular block of code would not get executed.

      <=> The alert on the GUI instead uses >> Weekday(Today()) << so that is evaluated immediately and of course

              it returns Friday and the alert fires correctly.

So how could I fix this? Could I use a different parameter in the script to make that function Today() in the script evaluate immediately?

Thanks a lot!

Best regards,

DataNibbler

P.S.: Unfortunately, that is very hard to check for the day will remain the same all day 😉 Could I try with a derivative of Now(0)?

datanibbler
Champion
Champion
Author

That is it!

I just replaced that >> Weekday(Today(0)) << with NOW(0) - and it read 06:00:13 - though right now it is 09:20 😉 So the parameter 0 does return the day of the last script_reload, not the current one.

I will try with the parameter 1 - for immediate evaluation.

Not applicable

that's great, good one to figure out