<?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 while $(a) &amp;gt; 0   vs.   while a &amp;gt; 0 in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/while-a-gt-0-vs-while-a-gt-0/m-p/946984#M326133</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am hoping someone can explain the following behavior:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When executing this code in the load script, it will result in a potentially infinite loop. Main thing, it doesn't stop when a = 0 but continues to count down in the negative numbers:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Let a = 10;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Do while $(a) &amp;gt; 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; TRACE $(a);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; Let a = a - 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Loop&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By just changing the line&amp;nbsp; &lt;SPAN style="font-family: 'courier new', courier; font-size: 13.3333330154419px;"&gt;Do while $(a) &amp;gt; 0 &lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;to&lt;/SPAN&gt; &lt;SPAN style="font-family: 'courier new', courier; font-size: 13.3333330154419px;"&gt;Do while a &amp;gt; 0 &lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;it works correctly.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does someone have the explanation for why referencing the variable without $( ) works but with it doesn't? Really would like to understand this.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 18 Aug 2015 14:53:41 GMT</pubDate>
    <dc:creator>bhorneber</dc:creator>
    <dc:date>2015-08-18T14:53:41Z</dc:date>
    <item>
      <title>while $(a) &gt; 0   vs.   while a &gt; 0</title>
      <link>https://community.qlik.com/t5/QlikView/while-a-gt-0-vs-while-a-gt-0/m-p/946984#M326133</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am hoping someone can explain the following behavior:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When executing this code in the load script, it will result in a potentially infinite loop. Main thing, it doesn't stop when a = 0 but continues to count down in the negative numbers:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Let a = 10;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Do while $(a) &amp;gt; 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; TRACE $(a);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; Let a = a - 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Loop&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By just changing the line&amp;nbsp; &lt;SPAN style="font-family: 'courier new', courier; font-size: 13.3333330154419px;"&gt;Do while $(a) &amp;gt; 0 &lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;to&lt;/SPAN&gt; &lt;SPAN style="font-family: 'courier new', courier; font-size: 13.3333330154419px;"&gt;Do while a &amp;gt; 0 &lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;it works correctly.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does someone have the explanation for why referencing the variable without $( ) works but with it doesn't? Really would like to understand this.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Aug 2015 14:53:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/while-a-gt-0-vs-while-a-gt-0/m-p/946984#M326133</guid>
      <dc:creator>bhorneber</dc:creator>
      <dc:date>2015-08-18T14:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: while $(a) &gt; 0   vs.   while a &gt; 0</title>
      <link>https://community.qlik.com/t5/QlikView/while-a-gt-0-vs-while-a-gt-0/m-p/946985#M326134</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You must write:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Let a = 10;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Do while $(a) &amp;gt; 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; TRACE $(a);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; Let a = $(a) - 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Loop&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;in this way you are correctly decreasing the value of a&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Aug 2015 14:57:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/while-a-gt-0-vs-while-a-gt-0/m-p/946985#M326134</guid>
      <dc:creator>alexandros17</dc:creator>
      <dc:date>2015-08-18T14:57:28Z</dc:date>
    </item>
    <item>
      <title>Re: while $(a) &gt; 0   vs.   while a &gt; 0</title>
      <link>https://community.qlik.com/t5/QlikView/while-a-gt-0-vs-while-a-gt-0/m-p/946986#M326135</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Because the $() expands to &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Do While 10 &amp;gt; 0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and the while loop is not executed again (trace step by step to see what i mean). So the &lt;SPAN style="font-size: 13.3333330154419px;"&gt;expansion is not evaluated again and the condition is &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;always true.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Aug 2015 14:58:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/while-a-gt-0-vs-while-a-gt-0/m-p/946986#M326135</guid>
      <dc:creator>jonathandienst</dc:creator>
      <dc:date>2015-08-18T14:58:26Z</dc:date>
    </item>
    <item>
      <title>Re: while $(a) &gt; 0   vs.   while a &gt; 0</title>
      <link>https://community.qlik.com/t5/QlikView/while-a-gt-0-vs-while-a-gt-0/m-p/946987#M326136</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;The help text says the same (although in something that looks like fine print): "... each condition is interpreted only the first time it is encountered but is evaluated for every time it&lt;/SPAN&gt;&lt;EM style="font-size: 10pt; line-height: 1.5em;"&gt; (sic)&lt;/EM&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; encountered in the loop", meaning that the $-sign substitution is indeed only applied once by the parser (at the very start) and the logical expression is probably translated into some kind of intermediate code (performance, you know) so that it quickly evaluates to either true or false.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Weird.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Edit] Eliminated irrelevant part of this comment&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Aug 2015 15:16:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/while-a-gt-0-vs-while-a-gt-0/m-p/946987#M326136</guid>
      <dc:creator>Peter_Cammaert</dc:creator>
      <dc:date>2015-08-18T15:16:46Z</dc:date>
    </item>
    <item>
      <title>Re: while $(a) &gt; 0   vs.   while a &gt; 0</title>
      <link>https://community.qlik.com/t5/QlikView/while-a-gt-0-vs-while-a-gt-0/m-p/946988#M326137</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Jonathan and Peter. &lt;/P&gt;&lt;P&gt;Clear and very helpful answers!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Aug 2015 15:54:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/while-a-gt-0-vs-while-a-gt-0/m-p/946988#M326137</guid>
      <dc:creator>bhorneber</dc:creator>
      <dc:date>2015-08-18T15:54:15Z</dc:date>
    </item>
    <item>
      <title>Re: while $(a) &gt; 0   vs.   while a &gt; 0</title>
      <link>https://community.qlik.com/t5/QlikView/while-a-gt-0-vs-while-a-gt-0/m-p/946989#M326138</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi benedikt,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"SET" means it takes the value after '=' operator as a string. to evaluate any operation like set a= 4+1 we use $(a).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could not do operations like ' set a = $(a)+1;'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you use the 'LET' then don't need $(variable).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in your case &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set a = 10; (or) let a=10;&lt;/P&gt;&lt;P&gt;do while a&amp;gt;0&lt;/P&gt;&lt;P&gt;trace $(a);&lt;/P&gt;&lt;P&gt;let a = a-1;&lt;/P&gt;&lt;P&gt;loop;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Aug 2015 16:18:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/while-a-gt-0-vs-while-a-gt-0/m-p/946989#M326138</guid>
      <dc:creator />
      <dc:date>2015-08-18T16:18:05Z</dc:date>
    </item>
  </channel>
</rss>

