<?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: $ sign expansion in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/sign-expansion/m-p/628270#M679499</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This makes sense now, I guess I was a bit lost as I'm just discovering Qlikview these days.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 12 May 2014 13:23:12 GMT</pubDate>
    <dc:creator />
    <dc:date>2014-05-12T13:23:12Z</dc:date>
    <item>
      <title>$ sign expansion</title>
      <link>https://community.qlik.com/t5/QlikView/sign-expansion/m-p/628264#M679493</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;In wonder why when I use $sign expansion in the condition of a do while instruction it doesn't work :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following code :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LET vCompteur = 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;DO while &lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;$(vCompteur)&lt;/STRONG&gt;&lt;/SPAN&gt; &amp;lt;= 10&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TRACE $(vCompteur);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LET vCompteur = $(vCompteur) + 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&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="text-decoration: underline;"&gt;results in an infinite loop&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;while the following code :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LET vCompteur = 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;DO while &lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;vCompteur&lt;/STRONG&gt;&lt;/SPAN&gt; &amp;lt;= 10&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TRACE $(vCompteur);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LET vCompteur = $(vCompteur) + 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&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;prints in the script execution console (as expected)&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;4&lt;/P&gt;&lt;P&gt;5&lt;/P&gt;&lt;P&gt;6&lt;/P&gt;&lt;P&gt;7&lt;/P&gt;&lt;P&gt;8&lt;/P&gt;&lt;P&gt;9&lt;/P&gt;&lt;P&gt;10&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have to say i'm kind of lost here, I tought $ sign expansion will return the value of vCompteur.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 May 2014 14:51:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/sign-expansion/m-p/628264#M679493</guid>
      <dc:creator />
      <dc:date>2014-05-09T14:51:23Z</dc:date>
    </item>
    <item>
      <title>Re: $ sign expansion</title>
      <link>https://community.qlik.com/t5/QlikView/sign-expansion/m-p/628265#M679494</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It works in this way because $ expansion computer again the expression and assign the value of 1 (as it was a constant) while the new variable value is stored in &lt;SPAN style="color: #3d3d3d; font-family: 'courier new', courier;"&gt;vCompteur&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 May 2014 15:00:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/sign-expansion/m-p/628265#M679494</guid>
      <dc:creator>alexandros17</dc:creator>
      <dc:date>2014-05-09T15:00:07Z</dc:date>
    </item>
    <item>
      <title>Re: $ sign expansion</title>
      <link>https://community.qlik.com/t5/QlikView/sign-expansion/m-p/628266#M679495</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 just don't seem to understand.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At the first loop, $ expansion will compute the expression and will find that vCompteur is equal 1. But in the loop the value of the variable vCompteur will change to 2 and then when $ expansion will compute the expression normally it should find that vCompteur is equal 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Something doesn't make sense, or maybe I'm missing something.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 May 2014 08:17:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/sign-expansion/m-p/628266#M679495</guid>
      <dc:creator />
      <dc:date>2014-05-12T08:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: $ sign expansion</title>
      <link>https://community.qlik.com/t5/QlikView/sign-expansion/m-p/628267#M679496</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Welcome to fun world of QlikView scripting &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I believe not all assumptions from common stock programming languages are working here.&lt;/P&gt;&lt;P&gt;To illustrate my point I slightly modified your script. It is still perfectly valid, and give correct output, though syntax highlighter not happy with lines 6-7 now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13998899703114249" jivemacro_uid="_13998899703114249" modifiedtitle="true"&gt;
&lt;P&gt;///$tab Main&lt;/P&gt;
&lt;P&gt;LET vCompteur = 1;&lt;/P&gt;
&lt;P&gt;LET whileVar = 'vCompteur';&lt;/P&gt;
&lt;P&gt;LET doWhile = 'DO while';&lt;/P&gt;
&lt;P&gt;LET whileCondition = '&amp;lt;= 10';&lt;/P&gt;
&lt;P&gt;$(doWhile) $(whileVar) $(whileCondition)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TRACE $(vCompteur);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LET vCompteur = $(vCompteur) + 1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LET whileVar = 'ABRAKADABRA';&lt;/P&gt;
&lt;P&gt;LOOP&lt;/P&gt;
&lt;P&gt;LET vCompteur=;&lt;/P&gt;
&lt;P&gt;LET whileVar=;&lt;/P&gt;
&lt;P&gt;LET doWhile=;&lt;/P&gt;
&lt;P&gt;LET whileCondition=;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best way to look at inner working of qlikview script engine is to step through script debugger.&lt;/P&gt;&lt;P&gt;Lets step through up to 6 line.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Debugger - Waiting 2014-05-12 16.44.27.png" class="jive-image" src="/legacyfs/online/58683_Debugger - Waiting 2014-05-12 16.44.27.png" style="width: 620px; height: 382px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Before debugger step into command line each occurence of $(something) in that line is textually replaced by its value in key/value map in right-bottom box (dictionary/map for variables). &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;If we step through futher we can see that debugger never return to line 6. Loop doing its job between lines 7-10.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;So our intentional distortion of variable whileVar do not break script either.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Firstly I intuitively think about $(someThing) as of evaluation of variable someThing. It's actually purely a string substitution (regex replace) on a stage before any evaluation.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;I hope it would clarify this vague behaviour.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 May 2014 11:08:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/sign-expansion/m-p/628267#M679496</guid>
      <dc:creator>vadimtsushko</dc:creator>
      <dc:date>2014-05-12T11:08:44Z</dc:date>
    </item>
    <item>
      <title>Re: $ sign expansion</title>
      <link>https://community.qlik.com/t5/QlikView/sign-expansion/m-p/628268#M679497</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;Actually your second script is actually the correct way to code this loop. Used this way vCompteur behaves like a variable in a normal language, and so does the do while loop&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To explain why the first one does not work - which is that the variable expansion happens before the script line is interpreted, this creates a compare between two number literals, not a variable and a number. The while condition is set up from this (once), hence an infinite loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH&lt;/P&gt;&lt;P&gt;Jonathan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 May 2014 11:26:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/sign-expansion/m-p/628268#M679497</guid>
      <dc:creator>jonathandienst</dc:creator>
      <dc:date>2014-05-12T11:26:13Z</dc:date>
    </item>
    <item>
      <title>Re: $ sign expansion</title>
      <link>https://community.qlik.com/t5/QlikView/sign-expansion/m-p/628269#M679498</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much for taking the time to explain it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is indeed a very strange behavior quite unlike what I'm used to see in Java or PL/SQL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you again&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 May 2014 11:30:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/sign-expansion/m-p/628269#M679498</guid>
      <dc:creator />
      <dc:date>2014-05-12T11:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: $ sign expansion</title>
      <link>https://community.qlik.com/t5/QlikView/sign-expansion/m-p/628270#M679499</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This makes sense now, I guess I was a bit lost as I'm just discovering Qlikview these days.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 May 2014 13:23:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/sign-expansion/m-p/628270#M679499</guid>
      <dc:creator />
      <dc:date>2014-05-12T13:23:12Z</dc:date>
    </item>
  </channel>
</rss>

