Qlik Community

Ask a Question

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Talk to Experts Tuesday, January 26th at 10AM EST: Qlik Sense. REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Creator II
Creator II

Include all subroutines from directory

Hi, 

I have a directory where all my subroutines are stored. I want to load them all at once, so that I can call every subroutine without the necessity to include the text file with the subroutine first. 

When I use Version A in the script (without a loop), everthing is fine:

 

//Version A:

$(Include=z:\documents\functions\CreateCalendar.txt);

Call CreateCalendar ('01.01.2018',Today());

 

But when I use the loop, it get an error (Syntax error Call >>>>>>CreateCalendar<<<<<< ('01.01.2018',Today()))

//Version B:
SET pathDataOrigin = 'z:\documents\functions\';

FOR Each File in filelist ('$(pathDataOrigin)'&'CreateCal*.txt')

$(Include=$(File));

Next File;

Call CreateCalendar ('01.01.2018',Today());

 

I cannot find the reason for the error. Can anyone help me with that?

 

 

 

 

The subroutine is very simple:

SUB CreateCalendar (StartDate, EndDate)


LET vDateMin = Num(StartDate);
LET vDateMax = Num(EndDate);


Calendar:
LOAD
Date($(vDateMin) + RowNo() - 1) AS Date
AUTOGENERATE 1
WHILE
$(vDateMin)+IterNo()-1<= $(vDateMax)
;

End Sub;

1 Solution

Accepted Solutions
Partner
Partner

A quick workaround is to create an include where you include all you functions. 

I am taking this example from the QDF:

A qvs including all you functions 

        LoadAll.jpg

Including the previous on your App 

   IncludeLoadAll.jpg

 

I hope this helps

 

 

 

View solution in original post

13 Replies
Creator II
Creator II

Hi, I mocked up your codes in my PC and i think the issue is happened with your sub.  I updated a little and it could return data for me. Also in your default date format setting, I updated to this: SET DateFormat='MM.DD.YYYY';

 

SUB CreateCalendar (StartDate, EndDate)


LET vDateMin = NUM(StartDate);
LET vDateMax = NUM(EndDate);


Calendar:
LOAD
Date('$(vDateMin)' + RowNo() - 1) AS Date
AUTOGENERATE 1
WHILE
'$(vDateMin)'+IterNo()-1<= '$(vDateMax)'
;

End Sub;

 

Thanks!

Partner
Partner

A quick workaround is to create an include where you include all you functions. 

I am taking this example from the QDF:

A qvs including all you functions 

        LoadAll.jpg

Including the previous on your App 

   IncludeLoadAll.jpg

 

I hope this helps

 

 

 

View solution in original post

Creator II
Creator II

I'm not sure what happened to my answer but it was removed somehow. So I re-posted here, 

SUB CreateCalendar (StartDate, EndDate)


LET vDateMin = NUM(StartDate);
LET vDateMax = NUM(EndDate);

	
	Calendar:
	LOAD
	Date('$(vDateMin)' + RowNo() - 1) AS Date
	AUTOGENERATE 1
	WHILE
	'$(vDateMin)'+IterNo()-1<= '$(vDateMax)'
	;

End Sub;

 I updated your sub and it's working for me now, also you need to watch out your date format to change to below:

SET DateFormat='MM.DD.YYYY';

Thanks! 

Creator II
Creator II

Hi, the sub itself was working as expected without the changes. But also with your changes, inserting it with the loop and then calling it leads to the described error.  

Creator II
Creator II

Hi,

 

thanks for this solution, but the workaround is not my prefered option, as I would state all function names explicitly when adding new subs. And when deleting subs, I would need to remove it from this list as well, ... I'd prefer a solution where changes don't need further effort.

Thank you! 

Creator II
Creator II

HI

Version B should be as follows

//Version B:
SET pathDataOrigin = 'z:\documents\functions\';

FOR Each File in filelist ('$(pathDataOrigin)CreateCal*.txt')

$(Include=$(File));

Next File

Call CreateCalendar ('01.01.2018',Today());

 

HTH

Regards

Adrian

MVP & Luminary
MVP & Luminary

Your logic itself should work - just run it within the debugger with a break point below the loop and then you could see within the various debugger-tabs your include-variables. I could imagine that you find the routine CreateCalendar or any other one several times … 

- Marcus

Creator II
Creator II

Hi,

I still get the same error. Did it work for you?

 

Kind Regards, Nigel

Creator II
Creator II

Hi, 

I've done that, and no, the routine just appears this one time. 

The debugger itself is not very helpful in this case. 

 

KR 

 

nigel987_0-1586884876511.png