Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

MUST_INCLUDE in Subroutine getting invoked prior to Subroutine being called

My script has a subroutine that contains a MUST_INCLUDE statement.

SUB GET_SOME_STUFF (box)
    
LET my_include= '..\..\Include\odbc-' & '$(box)' & '.qvs';
    
$(Must_Include=$(my_include));

      ......

      ......
END SUB;

LOAD BOXName
         ,
BOXType
   FROM [..\..\QVD\SYSTEM_INFO.qvd](qvd);

LET vNumBoxes=NoOfRows('BOX');
FOR i1=0 to $(vNumBoxes)-1
   
LET vBox=Peek('BOXName',$(i1),'BOX');
   
LET vVolCnt=peek('VOLCnt',$(i1),'BOX');
   
CALL GET_SOME_STUFF (vBox); 
NEXT

Prior to first call to subroutine the MUST_INCLUDE is getting invoked even though the subroutine has not been executed as of yet.  I can get around this problem by using INCLUDE instead of MUST_INCLUDE making the error silent, but find it odd that the statement is getting invoked at all prior to being called.  I would prefer to continue to use the MUST_INCLUDE as it insures my Include files exist.  Hoping someone else has run into this and has some suggestions.

1 Solution

Accepted Solutions
Not applicable

Re: MUST_INCLUDE in Subroutine getting invoked prior to Subroutine being called

I found a solution.  If I set the variable that holds the path to the include file to null prior to the SUB definition, the MUST_INCLUDE does not thow an error when the SUB gets defined, ex. my_include='' 

So it seems even though MUST_INCLUDE is still getting invoked on the initial subroutine definition, it does not throw an error when argument is null.

3 Replies
MVP
MVP

Re: MUST_INCLUDE in Subroutine getting invoked prior to Subroutine being called

try with an if and a variable

let v=0;

SUB GET_SOME_STUFF

  if $(v)=1 then

  trace must include;

  LET my_include= '.\aaa'  & '.qvs';

  $(Must_Include=$(my_include));

  ENDIF;

END SUB;

let v=1;

trace before;

CALL GET_SOME_STUFF; 

trace after;

Not applicable

Re: MUST_INCLUDE in Subroutine getting invoked prior to Subroutine being called

Hi Massimo, I tried your idea and it made no difference.  It appears that when a subroutine gets defined the MUST_INCLUDE gets invoked regardless -- I believe this is a bug

Not applicable

Re: MUST_INCLUDE in Subroutine getting invoked prior to Subroutine being called

I found a solution.  If I set the variable that holds the path to the include file to null prior to the SUB definition, the MUST_INCLUDE does not thow an error when the SUB gets defined, ex. my_include='' 

So it seems even though MUST_INCLUDE is still getting invoked on the initial subroutine definition, it does not throw an error when argument is null.

Community Browser