<?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: Subroutine within If Statement in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Subroutine-within-If-Statement/m-p/122724#M8516</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I believe it is a bug as well.&amp;nbsp; Tested in June 2018 and still doesn't work.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's a work-around.&amp;nbsp; Set a variable to the filename and then do the include outside the if statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Let vTrueFalse = -1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;//Let vTrueFalse = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;If $(vTrueFalse) then&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; let FileName = 'SubRoutine1.txt';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Else&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; let FileName = 'SubRoutine2.txt';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;EndIf&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;$(Include=[lib://AttachedFiles/$(FileName)]);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;If $(vTrueFalse) then&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Call SubRoutine1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Else&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Call SubRoutine2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;EndIf&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 13 Sep 2018 11:35:54 GMT</pubDate>
    <dc:creator>gwoodard</dc:creator>
    <dc:date>2018-09-13T11:35:54Z</dc:date>
    <item>
      <title>Subroutine within If Statement</title>
      <link>https://community.qlik.com/t5/App-Development/Subroutine-within-If-Statement/m-p/122722#M8514</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm marking this as a potential bug here so that my partner can reference it. I'm running Qlik Sense Server - April 2018.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Attached is an example of code where I load a subroutine at the beginning of my script based on a variable and then call the subroutine. In the first case, where the calling of the subroutine is within the same If statement, code execution completes without issue. However, if you switch the variable value to load the other subroutine, which is called further down in the script, you get a Semantic Error. Both subroutines are identical (empty) so it doesn't have anything to do with the code within them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone know if this is a bug or if Qlik intentionally limits the retention of the subroutine code to the bounds of an If statement?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Justin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2018 20:03:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Subroutine-within-If-Statement/m-p/122722#M8514</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-09-12T20:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: Subroutine within If Statement</title>
      <link>https://community.qlik.com/t5/App-Development/Subroutine-within-If-Statement/m-p/122723#M8515</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It strikes me as a bug. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2018 21:38:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Subroutine-within-If-Statement/m-p/122723#M8515</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2018-09-12T21:38:37Z</dc:date>
    </item>
    <item>
      <title>Re: Subroutine within If Statement</title>
      <link>https://community.qlik.com/t5/App-Development/Subroutine-within-If-Statement/m-p/122724#M8516</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I believe it is a bug as well.&amp;nbsp; Tested in June 2018 and still doesn't work.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's a work-around.&amp;nbsp; Set a variable to the filename and then do the include outside the if statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Let vTrueFalse = -1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;//Let vTrueFalse = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;If $(vTrueFalse) then&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; let FileName = 'SubRoutine1.txt';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Else&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; let FileName = 'SubRoutine2.txt';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;EndIf&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;$(Include=[lib://AttachedFiles/$(FileName)]);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;If $(vTrueFalse) then&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Call SubRoutine1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Else&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Call SubRoutine2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;EndIf&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Sep 2018 11:35:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Subroutine-within-If-Statement/m-p/122724#M8516</guid>
      <dc:creator>gwoodard</dc:creator>
      <dc:date>2018-09-13T11:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: Subroutine within If Statement</title>
      <link>https://community.qlik.com/t5/App-Development/Subroutine-within-If-Statement/m-p/122725#M8517</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's another reference to the same issue with an explanation:&amp;nbsp; &lt;A href="https://community.qlik.com/thread/246734"&gt;SUB inside IF ... THEN statement&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Sep 2018 11:39:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Subroutine-within-If-Statement/m-p/122725#M8517</guid>
      <dc:creator>gwoodard</dc:creator>
      <dc:date>2018-09-13T11:39:56Z</dc:date>
    </item>
    <item>
      <title>Re: Subroutine within If Statement</title>
      <link>https://community.qlik.com/t5/App-Development/Subroutine-within-If-Statement/m-p/1836022#M69067</link>
      <description>&lt;P&gt;I am really surprised this issue hasn't been taken up by R&amp;amp;D to fix yet.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyone know how we can get this bug in front of someone at Qlik?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Sep 2021 13:13:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Subroutine-within-If-Statement/m-p/1836022#M69067</guid>
      <dc:creator>cbushey1</dc:creator>
      <dc:date>2021-09-14T13:13:07Z</dc:date>
    </item>
  </channel>
</rss>

