Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

Problem with include

Is this my mistage or bug?

If INCLUDE is inside anykind of IF-clause it dosn't work!

Not work , display error message "Script line error: Call DropTables"

--------- NOT work ------------

SET QVscBase = 'JVR.SC';

IF NOT IsNull(QvdCreateTime('$(QvWorkPath)\$(QVscBase)')) then

          TRACE File $(QvWorkPath)\$(QVscBase) OK!;

          $(Include=$(QvWorkPath)\$(QVscBase));

ELSE

          TRACE File $(QvWorkPath)\$(QVscBase) not found!;

          EXIT Script;

ENDIF

Call DropTables;

-------------------------------

This work nicely

--------- work ------------

SET QVscBase = 'JVR.SC';

IF NOT IsNull(QvdCreateTime('$(QvWorkPath)\$(QVscBase)')) then

          TRACE File $(QvWorkPath)\$(QVscBase) OK!;

ELSE

          TRACE File $(QvWorkPath)\$(QVscBase) not found!;

          EXIT Script;

ENDIF

$(Include=$(QvWorkPath)\$(QVscBase));

Call DropTables;

-------------------------------

---------- JVR.SC -------------

SUB DropTables

          FOR i=nooftables()-1 TO 0 STEP -1

              LET vTable=tablename(i);

              DROP TABLE $(vTable);

          NEXT

          TRACE 'DropTables run OK';

ENDSUB

-------------------------------

1 Reply
MVP
MVP

Problem with include

Hi Jussi,

I believe the problem is not the include within the If-then-else, if you debug step through your code, you will see that it will be executed.

I think the problem is that the lifetime of your SUB routine is limited to the scope of the THEN statement part.

For example, if you add your CALL DropTables just after the include, it will work.

Probably you don't want to put all your code within that THEN statement code group.

I think what you can do is something like:

set QVscBase =./test.txt;

$(Include=$(QVscBase));

//let testTime = FileTime('$(QVscBase)');

If not isnull(FileTime('$(QVscBase)')) then

Trace Test1;

ELSE

Trace Test2;

exit script;

endif

Call DropTables;

i.e. including your code at the beginning (if the file does not exist, it won't throw an error, just doing nothing).

Then you might check for the existing of your file, exit if necessary.

then you can Call your SUB routines.

Hope this helps,

Stefan

Community Browser