<?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 SV:Controlling script execution using document variables in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Controlling-script-execution-using-document-variables/m-p/163974#M503709</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;If you set your variable in the app e.g. by an action or macro then the variable is directly available in the load script.&lt;/P&gt;&lt;P&gt;I have made a small example.&lt;/P&gt;&lt;P&gt;2 different INLINE loads are made depending on the variable value.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Jürg&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 26 May 2010 07:39:43 GMT</pubDate>
    <dc:creator />
    <dc:date>2010-05-26T07:39:43Z</dc:date>
    <item>
      <title>Controlling script execution using document variables</title>
      <link>https://community.qlik.com/t5/QlikView/Controlling-script-execution-using-document-variables/m-p/163969#M503704</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a series of script tabs each of which creates a qvd. This is all fine.&lt;/P&gt;&lt;P&gt;I want to be able to quickly select which parts of the script to reload and which parts not. I have been /*...*/ the bits I don't want.&lt;/P&gt;&lt;P&gt;Don't like that, so I have created a variable for each script section in the document, e.g. 201011AC can be 0 or 1.&lt;/P&gt;&lt;P&gt;I have tried to use IF...END IF around my script dependent upon 201011AC, e.g. :&lt;/P&gt;&lt;P&gt;IF 201011AC = 1 THEN&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;END IF&lt;/P&gt;&lt;P&gt;But this does not work and I get a "Script line error" for the IF statement line.&lt;/P&gt;&lt;P&gt;What do I need to do to get this to work?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Russell&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 May 2010 12:56:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Controlling-script-execution-using-document-variables/m-p/163969#M503704</guid>
      <dc:creator />
      <dc:date>2010-05-25T12:56:56Z</dc:date>
    </item>
    <item>
      <title>Controlling script execution using document variables</title>
      <link>https://community.qlik.com/t5/QlikView/Controlling-script-execution-using-document-variables/m-p/163970#M503705</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I use a folder for my fact QVD's and create a list of the available files in a list box.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;&lt;BR /&gt;&lt;BR /&gt;// available QVD files&lt;BR /&gt;// -------------------&lt;BR /&gt;For each File in filelist('$(QVDPath)\PunDay*.qvd')&lt;BR /&gt; namepos = index('$(File)','_') + 1;&lt;BR /&gt; AvailableDays:&lt;BR /&gt; LOAD mid('$(File)',$(namepos),10) as AvailableDay&lt;BR /&gt; , Weekday(date#(mid('$(File)',$(namepos),10),'yyyy-mm-dd')) as AvailableWeekday&lt;BR /&gt; Autogenerate 1;&lt;BR /&gt;Next File; &amp;lt;div&amp;gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;The user selects the files to load and presses a load button. I use a macro to set a variable&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt;&amp;lt;div&amp;gt;Sub LoopSelections()&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt;Control = ActiveDocument.Variables("vControl").GetContent.String &amp;lt;/div&amp;gt;&amp;lt;div&amp;gt;'msgbox "Control: " &amp;amp; Control&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt;Set oLB = ActiveDocument.getsheetobject(Control)&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt;sDates = ""&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt;'msgbox GetFieldSelections("AvailableMonth")&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt;' loop the ListBox items and create a comma separated variable with the entries&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt;sFiles = ""&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt;For iLoop = 0 To oLB.GetRowCount - 1&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt; ' item selected&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt; Set oCell = oLB.GetCell(iLoop,0)&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt; ' MsgBox "cell: " &amp;amp; oCell.Text &amp;amp; " state: " &amp;amp; oCell.State&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt; &amp;lt;/div&amp;gt;&amp;lt;div&amp;gt; If oCell.State &amp;lt; 3 Then&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt; ' for month selections use the first day of the month&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt; if len(oCell.Text) = 7 then&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt; sFiles = sFiles &amp;amp; oCell.Text &amp;amp; "-01,"&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt; else&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt; sFiles = sFiles &amp;amp; oCell.Text &amp;amp; ","&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt; end if &amp;lt;/div&amp;gt;&amp;lt;div&amp;gt; End If&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt;Next&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt;ActiveDocument.CreateVariable("vLoadFiles")&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt;ActiveDocument.GetVariable("vLoadFiles").SetContent sFiles,false &amp;lt;/div&amp;gt;&amp;lt;div&amp;gt;ActiveDocument.Reload&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt;End Sub&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;In the load script I loop over the selected qvd files&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt;&amp;lt;div&amp;gt; Let vNofFiles = substringcount('$(vLoadFiles)', ',');&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt; &amp;lt;/div&amp;gt;&amp;lt;div&amp;gt; For iLoop = 1 to vNofFiles&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt; &amp;lt;/div&amp;gt;&amp;lt;div&amp;gt; // build the file name in the form PunDay_YYYY-MM-DD&amp;lt;/div&amp;gt;&amp;lt;div&amp;gt; Let vCurrName = vType &amp;amp; '_' &amp;amp; SubField('$(vLoadFiles)', ',', iLoop) &amp;amp; '.QVD'; &amp;lt;/div&amp;gt;&amp;lt;div&amp;gt;... &amp;lt;/div&amp;gt;&amp;lt;div&amp;gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;because of the same structure the different QVD's get concatenated.&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Regards&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Jürg&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 May 2010 13:10:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Controlling-script-execution-using-document-variables/m-p/163970#M503705</guid>
      <dc:creator />
      <dc:date>2010-05-25T13:10:15Z</dc:date>
    </item>
    <item>
      <title>SV:Controlling script execution using document variables</title>
      <link>https://community.qlik.com/t5/QlikView/Controlling-script-execution-using-document-variables/m-p/163971#M503706</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We use this technique a lot.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let _DoThisPart = 0;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If _DoThisPart = 1 Then&lt;/P&gt;&lt;P&gt;// code that should only be used if _DoThisPart equals 1&lt;/P&gt;&lt;P&gt;End If // If _DoThisPart ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't now if the problem is that your variable name starts with a digit?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 May 2010 14:16:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Controlling-script-execution-using-document-variables/m-p/163971#M503706</guid>
      <dc:creator>gandalfgray</dc:creator>
      <dc:date>2010-05-25T14:16:02Z</dc:date>
    </item>
    <item>
      <title>SV:Controlling script execution using document variables</title>
      <link>https://community.qlik.com/t5/QlikView/Controlling-script-execution-using-document-variables/m-p/163972#M503707</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;STRONG&gt;Göran K,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Thanks for the post, but it does not get around my problem.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I want a document variable, which can be altered by the user, to be determining whether the script is run or not.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Your suggestion would still require the user to amend the variable within the script, i.e. change to Let _DoThisPart = 1.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;When I try to refer to any document variable, all I get is a string of the script, e.g.:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SET vRun = ActiveDocument.Variables("200809AC");&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;vRun is initialised as "ActiveDocument.Variables("200809AC")"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I have tried it with variable names beginning with v, but it makes no difference!&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;HELP!!?!?&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 May 2010 14:54:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Controlling-script-execution-using-document-variables/m-p/163972#M503707</guid>
      <dc:creator />
      <dc:date>2010-05-25T14:54:36Z</dc:date>
    </item>
    <item>
      <title>SV:Controlling script execution using document variables</title>
      <link>https://community.qlik.com/t5/QlikView/Controlling-script-execution-using-document-variables/m-p/163973#M503708</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't know if this helps but I think I am right in syaing that QlikView does not understand the concept of ActiveDocument when it is running the script, so you assignment to a variable in run time to affect the load script I don't think will work.&lt;/P&gt;&lt;P&gt;Not sure if there is any workaround for this, sorry.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 May 2010 17:11:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Controlling-script-execution-using-document-variables/m-p/163973#M503708</guid>
      <dc:creator />
      <dc:date>2010-05-25T17:11:42Z</dc:date>
    </item>
    <item>
      <title>SV:Controlling script execution using document variables</title>
      <link>https://community.qlik.com/t5/QlikView/Controlling-script-execution-using-document-variables/m-p/163974#M503709</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;If you set your variable in the app e.g. by an action or macro then the variable is directly available in the load script.&lt;/P&gt;&lt;P&gt;I have made a small example.&lt;/P&gt;&lt;P&gt;2 different INLINE loads are made depending on the variable value.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Jürg&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 May 2010 07:39:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Controlling-script-execution-using-document-variables/m-p/163974#M503709</guid>
      <dc:creator />
      <dc:date>2010-05-26T07:39:43Z</dc:date>
    </item>
    <item>
      <title>SV:Controlling script execution using document variables</title>
      <link>https://community.qlik.com/t5/QlikView/Controlling-script-execution-using-document-variables/m-p/163975#M503710</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Juerg, this is the perfect solution to my problem.&lt;/P&gt;&lt;P&gt;Couple of points for anyone else following this thread:&lt;/P&gt;&lt;P&gt;name your variables starting with a letter not a number&lt;/P&gt;&lt;P&gt;remember to add a trailing semi-colon to the end if statement!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 May 2010 09:43:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Controlling-script-execution-using-document-variables/m-p/163975#M503710</guid>
      <dc:creator />
      <dc:date>2010-05-27T09:43:15Z</dc:date>
    </item>
  </channel>
</rss>

