<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Include all subroutines from directory in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Include-all-subroutines-from-directory/m-p/1694367#M450835</link>
    <description>&lt;P&gt;I just dived a bit deeper in the matter and think you are right that it's not working in this way - without that there are "obvious" logically or syntactically errors. Every part "seemed" to be loaded and executed in the right order.&lt;/P&gt;&lt;P&gt;But it's not completely true. The cause of the sub-error here is that the sub-routine was created within a control-statement.&lt;/P&gt;&lt;P&gt;Control-statements like sub … end sub, if … end if, for … next have special properties in regard to their validity. This means either the existence and execution-order of them as well as the objects (tables, variables, further control-statements) which are created within them. This means they aren't available from everywhere.&lt;/P&gt;&lt;P&gt;In your case it means the sub was created within the for-loop and is only within the loop available and each call from the outside called a non exists statement.&lt;/P&gt;&lt;P&gt;I don't know if it's anywhere sufficient documented how Qlik has implemented the control-statements and which requirements are following from it. I remember that I have seen already postings where the guru's discussed this topic - maybe&amp;nbsp;&lt;A href="https://community.qlik.com/t5/user/viewprofilepage/user-id/6148" target="_self"&gt;Rob Wunderlich&lt;/A&gt;&amp;nbsp; could shed some light on the matter.&lt;/P&gt;&lt;P&gt;In the end I doubt that there is a way to apply your mentioned approach and that the already made suggestion of applying multiple (nested) include-variables is probably the most suitable solution (I use this approach since many years and it's IMO quite practical).&lt;/P&gt;&lt;P&gt;Nevertheless I tried to develop a workaround with a logic which loads these include-files within a table, aggregated the records, creates multiple variables within a loop, called them outside from the loop, executed the routines and cleanes everything. It worked - but it's not really simpler and you will further need to specify each variable … but maybe somebody has further ideas to make this snippet more useful:&lt;/P&gt;&lt;DIV&gt;&lt;FONT&gt;set pathDataOrigin = 'YourPath\';&lt;BR /&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;for each File in filelist ('$(pathDataOrigin)CalendarIncludeT*.txt')&lt;BR /&gt;&amp;nbsp;&amp;nbsp; t1: load [@1:n] as Statement, filebasename() as Filebasename, rowno() as RowNo from [$(File)] (fix, codepage is 1252);&amp;nbsp;&lt;BR /&gt;next File&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;t2: load Filebasename, concat(Statement, chr(10), RowNo) as Statement resident t1 group by Filebasename;&lt;BR /&gt;drop tables t1;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;for i = 0 to noofrows('t2') - 1&lt;BR /&gt;&amp;nbsp;&amp;nbsp; let s$(i) = peek('Statement', $(i), 't2');&lt;BR /&gt;&amp;nbsp;&amp;nbsp; $(s$(i));&lt;BR /&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;next&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;$(s0);&lt;BR /&gt;$(s1);&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;call CreateCalendar('01.01.2018',Today());&lt;BR /&gt;call CreateCalendarMonth('01.01.2018',Today());&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;for i = 0 to noofrows('t2') - 1&lt;BR /&gt;&amp;nbsp;&amp;nbsp; let s$(i) = null();&lt;BR /&gt;next&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;let i = null();&lt;BR /&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just came another thought that the above mentioned control-statements are the most usual ones but there more available like do while loop, case switch, … and maybe there are any differences how their validity worked ... in the case you want a bit play with them ...&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;</description>
    <pubDate>Fri, 17 Apr 2020 09:15:56 GMT</pubDate>
    <dc:creator>marcus_sommer</dc:creator>
    <dc:date>2020-04-17T09:15:56Z</dc:date>
    <item>
      <title>Include all subroutines from directory</title>
      <link>https://community.qlik.com/t5/QlikView/Include-all-subroutines-from-directory/m-p/1692869#M450730</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I use Version A in the script (without a loop), everthing is fine:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//Version A:&lt;/P&gt;&lt;P&gt;$(Include=z:\documents\functions\CreateCalendar.txt);&lt;/P&gt;&lt;P&gt;Call CreateCalendar ('01.01.2018',Today());&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when I use the loop, it get an error (Syntax error&amp;nbsp;Call &amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;CreateCalendar&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; ('01.01.2018',Today()))&lt;/P&gt;&lt;P&gt;//Version B:&lt;BR /&gt;SET pathDataOrigin = 'z:\documents\functions\';&lt;/P&gt;&lt;P&gt;FOR Each File in filelist ('$(pathDataOrigin)'&amp;amp;'CreateCal*.txt')&lt;/P&gt;&lt;P&gt;$(Include=$(File));&lt;/P&gt;&lt;P&gt;Next File;&lt;/P&gt;&lt;P&gt;Call CreateCalendar ('01.01.2018',Today());&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cannot find the reason for the error. Can anyone help me with that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The subroutine is very simple:&lt;/P&gt;&lt;P&gt;SUB CreateCalendar (StartDate, EndDate)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;LET vDateMin = Num(StartDate);&lt;BR /&gt;LET vDateMax = Num(EndDate);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Calendar:&lt;BR /&gt;LOAD&lt;BR /&gt;Date($(vDateMin) + RowNo() - 1) AS Date&lt;BR /&gt;AUTOGENERATE 1&lt;BR /&gt;WHILE&lt;BR /&gt;$(vDateMin)+IterNo()-1&amp;lt;= $(vDateMax)&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;End Sub;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Apr 2020 15:58:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Include-all-subroutines-from-directory/m-p/1692869#M450730</guid>
      <dc:creator>nigel987</dc:creator>
      <dc:date>2020-04-12T15:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: Include all subroutines from directory</title>
      <link>https://community.qlik.com/t5/QlikView/Include-all-subroutines-from-directory/m-p/1692887#M450731</link>
      <description>&lt;P&gt;Hi, I mocked up your codes in my PC and i think the issue is happened with your sub.&amp;nbsp; 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';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;SUB CreateCalendar (StartDate, EndDate)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;EM&gt;LET vDateMin = NUM(StartDate);&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;LET vDateMax = NUM(EndDate);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;EM&gt;Calendar:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;LOAD&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Date('$(vDateMin)' + RowNo() - 1) AS Date&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;AUTOGENERATE 1&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;WHILE&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;'$(vDateMin)'+IterNo()-1&amp;lt;= '$(vDateMax)'&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;End Sub;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2020 02:15:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Include-all-subroutines-from-directory/m-p/1692887#M450731</guid>
      <dc:creator>alex00321</dc:creator>
      <dc:date>2020-04-13T02:15:39Z</dc:date>
    </item>
    <item>
      <title>Re: Include all subroutines from directory</title>
      <link>https://community.qlik.com/t5/QlikView/Include-all-subroutines-from-directory/m-p/1692899#M450735</link>
      <description>&lt;P&gt;A quick workaround is to create an include where you include all you functions.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am taking this example from the QDF:&lt;/P&gt;&lt;P&gt;A qvs including all you functions&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LoadAll.jpg" style="width: 640px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/31711i1F935B950848A750/image-size/large?v=v2&amp;amp;px=999" role="button" title="LoadAll.jpg" alt="LoadAll.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Including the previous on your App&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="IncludeLoadAll.jpg" style="width: 792px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/31712i2C89E0E15CC50A84/image-size/large?v=v2&amp;amp;px=999" role="button" title="IncludeLoadAll.jpg" alt="IncludeLoadAll.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this helps&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2020 04:43:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Include-all-subroutines-from-directory/m-p/1692899#M450735</guid>
      <dc:creator>albertovarela</dc:creator>
      <dc:date>2020-04-13T04:43:02Z</dc:date>
    </item>
    <item>
      <title>Re: Include all subroutines from directory</title>
      <link>https://community.qlik.com/t5/QlikView/Include-all-subroutines-from-directory/m-p/1692905#M450736</link>
      <description>&lt;P&gt;I'm not sure what happened to my answer but it was removed somehow. So I re-posted here,&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;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&amp;lt;= '$(vDateMax)'
	;

End Sub;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;I updated your sub and it's working for me now, also you need to watch out your date format to change to below:&lt;/P&gt;&lt;P&gt;SET DateFormat='MM.DD.YYYY';&lt;/P&gt;&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2020 06:04:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Include-all-subroutines-from-directory/m-p/1692905#M450736</guid>
      <dc:creator>alex00321</dc:creator>
      <dc:date>2020-04-13T06:04:07Z</dc:date>
    </item>
    <item>
      <title>Re: Include all subroutines from directory</title>
      <link>https://community.qlik.com/t5/QlikView/Include-all-subroutines-from-directory/m-p/1693049#M450745</link>
      <description>&lt;P&gt;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.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2020 17:00:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Include-all-subroutines-from-directory/m-p/1693049#M450745</guid>
      <dc:creator>nigel987</dc:creator>
      <dc:date>2020-04-13T17:00:06Z</dc:date>
    </item>
    <item>
      <title>Re: Include all subroutines from directory</title>
      <link>https://community.qlik.com/t5/QlikView/Include-all-subroutines-from-directory/m-p/1693051#M450746</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2020 17:09:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Include-all-subroutines-from-directory/m-p/1693051#M450746</guid>
      <dc:creator>nigel987</dc:creator>
      <dc:date>2020-04-13T17:09:30Z</dc:date>
    </item>
    <item>
      <title>Re: Include all subroutines from directory</title>
      <link>https://community.qlik.com/t5/QlikView/Include-all-subroutines-from-directory/m-p/1693247#M450769</link>
      <description>&lt;P&gt;HI&lt;/P&gt;&lt;P&gt;Version B should be as follows&lt;/P&gt;&lt;P&gt;//Version B:&lt;BR /&gt;SET pathDataOrigin = 'z:\documents\functions\';&lt;/P&gt;&lt;P&gt;FOR Each File in filelist ('$(pathDataOrigin)CreateCal*.txt')&lt;/P&gt;&lt;P&gt;$(Include=$(File));&lt;/P&gt;&lt;P&gt;Next File&lt;/P&gt;&lt;P&gt;Call CreateCalendar ('01.01.2018',Today());&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;HTH&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Adrian&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 11:52:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Include-all-subroutines-from-directory/m-p/1693247#M450769</guid>
      <dc:creator>atoz1158</dc:creator>
      <dc:date>2020-04-14T11:52:22Z</dc:date>
    </item>
    <item>
      <title>Re: Include all subroutines from directory</title>
      <link>https://community.qlik.com/t5/QlikView/Include-all-subroutines-from-directory/m-p/1693285#M450774</link>
      <description>&lt;P&gt;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&amp;nbsp;&lt;SPAN&gt;CreateCalendar &lt;/SPAN&gt;or any other one several times …&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 13:19:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Include-all-subroutines-from-directory/m-p/1693285#M450774</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2020-04-14T13:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: Include all subroutines from directory</title>
      <link>https://community.qlik.com/t5/QlikView/Include-all-subroutines-from-directory/m-p/1693403#M450780</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I still get the same error. Did it work for you?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind Regards, Nigel&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 17:18:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Include-all-subroutines-from-directory/m-p/1693403#M450780</guid>
      <dc:creator>nigel987</dc:creator>
      <dc:date>2020-04-14T17:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: Include all subroutines from directory</title>
      <link>https://community.qlik.com/t5/QlikView/Include-all-subroutines-from-directory/m-p/1693406#M450781</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've done that, and no, the routine just appears this one time.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The debugger itself is not very helpful in this case.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;KR&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="nigel987_0-1586884876511.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/31816i380B59D7B9A3CFE8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="nigel987_0-1586884876511.png" alt="nigel987_0-1586884876511.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 17:22:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Include-all-subroutines-from-directory/m-p/1693406#M450781</guid>
      <dc:creator>nigel987</dc:creator>
      <dc:date>2020-04-14T17:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: Include all subroutines from directory</title>
      <link>https://community.qlik.com/t5/QlikView/Include-all-subroutines-from-directory/m-p/1693554#M450792</link>
      <description>&lt;P&gt;There is no breaking point (right click on the row-number will set/remove one) set and therefore it just runs into an error without giving you the possibility to monitor what's loaded within the include-file - you noticed that there is now another tab above the debugger-script-window?&lt;/P&gt;&lt;P&gt;Because of the fact that this tab/window is created and is called CreateCalendar I assume that the include-file is really loaded - in the most cases it's exactly the reason (an invalid path) why anything didn't work. Nevertheless you may to ensure that it worked like expected and if not to trace the issue - for this you should use &lt;STRONG&gt;must_&lt;/STRONG&gt;include instead of include and &lt;STRONG&gt;TRACE $(File);&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;Therefore I think that there is something wrong with your sub-routine probably any small syntax-issue, for example I noticed that there is a space between the routine-name and the parameter (I'm not sure if it lead to an error) ...&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 07:00:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Include-all-subroutines-from-directory/m-p/1693554#M450792</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2020-04-15T07:00:11Z</dc:date>
    </item>
    <item>
      <title>Re: Include all subroutines from directory</title>
      <link>https://community.qlik.com/t5/QlikView/Include-all-subroutines-from-directory/m-p/1694166#M450824</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/28038"&gt;@marcus_sommer&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;you're right, you can't see a breaking point in the screenshot, because I debugged step-by-step. And yes, I noticed the new tab with the sub, hence I assume that the sub is loaded properly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I know that the sub itself is working, because when I include this file only (Version A) it works as expected.&amp;nbsp;&lt;/P&gt;&lt;P&gt;//Version A:&lt;BR /&gt;$(Include=z:\documents\functions\CreateCalendar.txt);&lt;BR /&gt;Call CreateCalendar('01.01.2018',Today());&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But still, when using the loop, I cannot get it running, and the debugger isn't helpful either.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SUB CreateCalendar(StartDate, EndDate)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;LET vDateMin = Num(StartDate);&lt;BR /&gt;LET vDateMax = Num(EndDate);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Calendar:&lt;BR /&gt;LOAD&lt;BR /&gt;Date('$(vDateMin)' + RowNo() - 1) AS Date&lt;BR /&gt;AUTOGENERATE 1&lt;BR /&gt;WHILE&lt;BR /&gt;'$(vDateMin)'+IterNo()-1&amp;lt;= '$(vDateMax)'&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;End Sub;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Apr 2020 16:58:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Include-all-subroutines-from-directory/m-p/1694166#M450824</guid>
      <dc:creator>nigel987</dc:creator>
      <dc:date>2020-04-16T16:58:34Z</dc:date>
    </item>
    <item>
      <title>Re: Include all subroutines from directory</title>
      <link>https://community.qlik.com/t5/QlikView/Include-all-subroutines-from-directory/m-p/1694367#M450835</link>
      <description>&lt;P&gt;I just dived a bit deeper in the matter and think you are right that it's not working in this way - without that there are "obvious" logically or syntactically errors. Every part "seemed" to be loaded and executed in the right order.&lt;/P&gt;&lt;P&gt;But it's not completely true. The cause of the sub-error here is that the sub-routine was created within a control-statement.&lt;/P&gt;&lt;P&gt;Control-statements like sub … end sub, if … end if, for … next have special properties in regard to their validity. This means either the existence and execution-order of them as well as the objects (tables, variables, further control-statements) which are created within them. This means they aren't available from everywhere.&lt;/P&gt;&lt;P&gt;In your case it means the sub was created within the for-loop and is only within the loop available and each call from the outside called a non exists statement.&lt;/P&gt;&lt;P&gt;I don't know if it's anywhere sufficient documented how Qlik has implemented the control-statements and which requirements are following from it. I remember that I have seen already postings where the guru's discussed this topic - maybe&amp;nbsp;&lt;A href="https://community.qlik.com/t5/user/viewprofilepage/user-id/6148" target="_self"&gt;Rob Wunderlich&lt;/A&gt;&amp;nbsp; could shed some light on the matter.&lt;/P&gt;&lt;P&gt;In the end I doubt that there is a way to apply your mentioned approach and that the already made suggestion of applying multiple (nested) include-variables is probably the most suitable solution (I use this approach since many years and it's IMO quite practical).&lt;/P&gt;&lt;P&gt;Nevertheless I tried to develop a workaround with a logic which loads these include-files within a table, aggregated the records, creates multiple variables within a loop, called them outside from the loop, executed the routines and cleanes everything. It worked - but it's not really simpler and you will further need to specify each variable … but maybe somebody has further ideas to make this snippet more useful:&lt;/P&gt;&lt;DIV&gt;&lt;FONT&gt;set pathDataOrigin = 'YourPath\';&lt;BR /&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;for each File in filelist ('$(pathDataOrigin)CalendarIncludeT*.txt')&lt;BR /&gt;&amp;nbsp;&amp;nbsp; t1: load [@1:n] as Statement, filebasename() as Filebasename, rowno() as RowNo from [$(File)] (fix, codepage is 1252);&amp;nbsp;&lt;BR /&gt;next File&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;t2: load Filebasename, concat(Statement, chr(10), RowNo) as Statement resident t1 group by Filebasename;&lt;BR /&gt;drop tables t1;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;for i = 0 to noofrows('t2') - 1&lt;BR /&gt;&amp;nbsp;&amp;nbsp; let s$(i) = peek('Statement', $(i), 't2');&lt;BR /&gt;&amp;nbsp;&amp;nbsp; $(s$(i));&lt;BR /&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;next&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;$(s0);&lt;BR /&gt;$(s1);&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;call CreateCalendar('01.01.2018',Today());&lt;BR /&gt;call CreateCalendarMonth('01.01.2018',Today());&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;for i = 0 to noofrows('t2') - 1&lt;BR /&gt;&amp;nbsp;&amp;nbsp; let s$(i) = null();&lt;BR /&gt;next&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;let i = null();&lt;BR /&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just came another thought that the above mentioned control-statements are the most usual ones but there more available like do while loop, case switch, … and maybe there are any differences how their validity worked ... in the case you want a bit play with them ...&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2020 09:15:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Include-all-subroutines-from-directory/m-p/1694367#M450835</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2020-04-17T09:15:56Z</dc:date>
    </item>
    <item>
      <title>Re: Include all subroutines from directory</title>
      <link>https://community.qlik.com/t5/QlikView/Include-all-subroutines-from-directory/m-p/1694607#M450849</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/28038"&gt;@marcus_sommer&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;many thanks for your elaborate explanation. I wasn't aware of the fact, that control statements behave in this way. Now I understand why the workaround as suggested by&amp;nbsp;&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/25613"&gt;@albertovarela&lt;/a&gt;&amp;nbsp;is so extensively used, and I&amp;nbsp;guess it is okay to use it, as it can be expected that functions are not changed very often. Understanding the reason behind this solution makes it even more acceptible. Thanks for shedding light on this topic.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;Nigel&lt;/P&gt;</description>
      <pubDate>Sat, 18 Apr 2020 17:17:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Include-all-subroutines-from-directory/m-p/1694607#M450849</guid>
      <dc:creator>nigel987</dc:creator>
      <dc:date>2020-04-18T17:17:47Z</dc:date>
    </item>
  </channel>
</rss>

