Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
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
Author

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.

View solution in original post

3 Replies
maxgro
MVP
MVP

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
Author

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
Author

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.