<?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: Check if exists - Script file in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Check-if-exists-Script-file/m-p/1365734#M418004</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks for the reply mw. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I ended up doing something a bit more elaborate to incorporate the loop functionality with my Must_includes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SET vRoot = '..\..\..\..\SQL Script Library\';&lt;/P&gt;&lt;P&gt;/* Builds a list of Only Custom scripts in the folder*/&lt;/P&gt;&lt;P&gt;FOR Each Ext in 'qvs'&lt;/P&gt;&lt;P&gt;// &lt;/P&gt;&lt;P&gt;&amp;nbsp; FOR Each File in filelist ('$(vRoot)'&amp;amp;'\*.'&amp;amp;Ext)&lt;/P&gt;&lt;P&gt;ScriptList: &lt;/P&gt;&lt;P&gt;Load &lt;/P&gt;&lt;P&gt; SubField('$(File)','\',-1) as ScriptFullName&lt;/P&gt;&lt;P&gt;, SubField(SubField(SubField('$(File)','\',-1),'_',1),'.',1) as GenericScriptName&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;autogenerate 1&lt;/P&gt;&lt;P&gt;Where SubField('$(File)','\',-1) like '*_BD*';&lt;/P&gt;&lt;P&gt;next File&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; FOR Each File in filelist ('$(vRoot)'&amp;amp;'\*.'&amp;amp;Ext)&lt;/P&gt;&lt;P&gt;Concatenate (ScriptList)&lt;/P&gt;&lt;P&gt;Load &lt;/P&gt;&lt;P&gt; SubField('$(File)','\',-1) as ScriptFullName&lt;/P&gt;&lt;P&gt;, SubField(SubField(SubField('$(File)','\',-1),'_',1),'.',1) as GenericScriptName&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;autogenerate 1&lt;/P&gt;&lt;P&gt;Where NOT EXISTS(GenericScriptName,SubField(SubField(SubField('$(File)','\',-1),'_',1),'.',1));&lt;/P&gt;&lt;P&gt;next File&lt;/P&gt;&lt;P&gt;next Ext&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Loop and load the the must_include statements for all the scripts that are required for this client */&lt;/P&gt;&lt;P&gt;For i = 1 to NoOfRows('ScriptList')&lt;/P&gt;&lt;P&gt;Let vFileName = Peek('ScriptFullName',$(i),'ScriptList');&lt;/P&gt;&lt;P&gt;$(Must_Include='..\..\..\..\SQL Script Library\$(vFileName)');&lt;/P&gt;&lt;P&gt;Next i&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DROP TABLES ScriptList;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 27 Jun 2017 17:23:11 GMT</pubDate>
    <dc:creator>cbushey1</dc:creator>
    <dc:date>2017-06-27T17:23:11Z</dc:date>
    <item>
      <title>Check if exists - Script file</title>
      <link>https://community.qlik.com/t5/QlikView/Check-if-exists-Script-file/m-p/1365732#M418002</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Fellow Qlikies, I am trying to check if a script file (.qvs) exists inside a folder and if it does load it, else load a different one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If this exists in the file directory (SomeScript_BD.qvs) then use the must_Include to read it into the application, if it doesnt exist, use the Must_Include for this file (&lt;SPAN style="font-size: 13.3333px;"&gt;SomeScript.qvs).&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;As I write this I am thinking I might be able to create a table use DoDir approach that lists all the filenames as fields and then if use a function to check if the filename exists in this list.&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;Does anyone have any thoughts?&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;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Jun 2017 14:14:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Check-if-exists-Script-file/m-p/1365732#M418002</guid>
      <dc:creator>cbushey1</dc:creator>
      <dc:date>2017-06-27T14:14:17Z</dc:date>
    </item>
    <item>
      <title>Re: Check if exists - Script file</title>
      <link>https://community.qlik.com/t5/QlikView/Check-if-exists-Script-file/m-p/1365733#M418003</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Let vFile&amp;nbsp;&amp;nbsp;&amp;nbsp; = 'Your first qvs file path';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET vFileExists = if(FileSize('$(vFile)') &amp;gt; 0, -1, 0);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF $(vFileExists) THEN&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Must_include the first file here &lt;/P&gt;&lt;P&gt;ELSE // File does not exist&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Must_include the Second file here&amp;nbsp; &lt;/P&gt;&lt;P&gt;ENDIF &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Jun 2017 15:13:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Check-if-exists-Script-file/m-p/1365733#M418003</guid>
      <dc:creator>m_woolf</dc:creator>
      <dc:date>2017-06-27T15:13:14Z</dc:date>
    </item>
    <item>
      <title>Re: Check if exists - Script file</title>
      <link>https://community.qlik.com/t5/QlikView/Check-if-exists-Script-file/m-p/1365734#M418004</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks for the reply mw. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I ended up doing something a bit more elaborate to incorporate the loop functionality with my Must_includes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SET vRoot = '..\..\..\..\SQL Script Library\';&lt;/P&gt;&lt;P&gt;/* Builds a list of Only Custom scripts in the folder*/&lt;/P&gt;&lt;P&gt;FOR Each Ext in 'qvs'&lt;/P&gt;&lt;P&gt;// &lt;/P&gt;&lt;P&gt;&amp;nbsp; FOR Each File in filelist ('$(vRoot)'&amp;amp;'\*.'&amp;amp;Ext)&lt;/P&gt;&lt;P&gt;ScriptList: &lt;/P&gt;&lt;P&gt;Load &lt;/P&gt;&lt;P&gt; SubField('$(File)','\',-1) as ScriptFullName&lt;/P&gt;&lt;P&gt;, SubField(SubField(SubField('$(File)','\',-1),'_',1),'.',1) as GenericScriptName&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;autogenerate 1&lt;/P&gt;&lt;P&gt;Where SubField('$(File)','\',-1) like '*_BD*';&lt;/P&gt;&lt;P&gt;next File&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; FOR Each File in filelist ('$(vRoot)'&amp;amp;'\*.'&amp;amp;Ext)&lt;/P&gt;&lt;P&gt;Concatenate (ScriptList)&lt;/P&gt;&lt;P&gt;Load &lt;/P&gt;&lt;P&gt; SubField('$(File)','\',-1) as ScriptFullName&lt;/P&gt;&lt;P&gt;, SubField(SubField(SubField('$(File)','\',-1),'_',1),'.',1) as GenericScriptName&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;autogenerate 1&lt;/P&gt;&lt;P&gt;Where NOT EXISTS(GenericScriptName,SubField(SubField(SubField('$(File)','\',-1),'_',1),'.',1));&lt;/P&gt;&lt;P&gt;next File&lt;/P&gt;&lt;P&gt;next Ext&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Loop and load the the must_include statements for all the scripts that are required for this client */&lt;/P&gt;&lt;P&gt;For i = 1 to NoOfRows('ScriptList')&lt;/P&gt;&lt;P&gt;Let vFileName = Peek('ScriptFullName',$(i),'ScriptList');&lt;/P&gt;&lt;P&gt;$(Must_Include='..\..\..\..\SQL Script Library\$(vFileName)');&lt;/P&gt;&lt;P&gt;Next i&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DROP TABLES ScriptList;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Jun 2017 17:23:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Check-if-exists-Script-file/m-p/1365734#M418004</guid>
      <dc:creator>cbushey1</dc:creator>
      <dc:date>2017-06-27T17:23:11Z</dc:date>
    </item>
  </channel>
</rss>

