<?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 to see if a list is empty in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Check-to-see-if-a-list-is-empty/m-p/8046#M8040</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;EM&gt;Is Missing()&lt;/EM&gt; on an empty list will return an empty list, because it is operating on each element of a list.&amp;nbsp; If the list is empty, there are no elements for &lt;EM&gt;Is Missing()&lt;/EM&gt; to operate on, so it returns the empty list.&amp;nbsp; However, a better way to see this is the following example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;lst = {1,2,.,""};&lt;/P&gt;&lt;P&gt;ismissing(lst);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 29 Jan 2014 01:42:22 GMT</pubDate>
    <dc:creator>michael_jmp</dc:creator>
    <dc:date>2014-01-29T01:42:22Z</dc:date>
    <item>
      <title>Check to see if a list is empty</title>
      <link>https://community.jmp.com/t5/Discussions/Check-to-see-if-a-list-is-empty/m-p/8044#M8038</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; This may be an easy question to answer but what I am trying to do is use JMP&amp;nbsp; to count the number of files contained within a specific directory and return a value of either 0 if none exist or the number of files.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know that using the Files In Directory function will list the files contained as a list but what I want to do is convert this to a numerical value:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ie:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote" modifiedtitle="true"&gt;&lt;BR /&gt;&lt;P&gt;//set up raw dir&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;raw_dir = "C:\\My PhotoFilmStrips\";&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;_files = Files In Directory( raw_dir );&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;//show files&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;show(_files);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;show( Type(_files), Is Empty(_files), Is Missing(_files), _files==Empty());&lt;/P&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;If I run the above script i get the following with a file contained within the raw directory:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Type(_files) = "List";&lt;/P&gt;&lt;P&gt;Is Empty(_files) = 0;&lt;/P&gt;&lt;P&gt;Is Missing(_files) = {0};&lt;/P&gt;&lt;P&gt;_files == Empty() = 0;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When the directory is empty I get:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Type(_files) = "Number";&lt;/P&gt;&lt;P&gt;Is Empty(_files) = 0;&lt;/P&gt;&lt;P&gt;Is Missing(_files) = 1;&lt;/P&gt;&lt;P&gt;_files == Empty() = .;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I make use of the Is Missing variable - ie if it is 1 then assign the number to a variable like tt=0 and when it the Is Missing variable is 0 then tt=1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be appreciated&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rgds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Colin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 25 Jan 2014 18:03:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Check-to-see-if-a-list-is-empty/m-p/8044#M8038</guid>
      <dc:creator>lodey101</dc:creator>
      <dc:date>2014-01-25T18:03:23Z</dc:date>
    </item>
    <item>
      <title>Re: Check to see if a list is empty</title>
      <link>https://community.jmp.com/t5/Discussions/Check-to-see-if-a-list-is-empty/m-p/8045#M8039</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In JMP 10 and 11 an empty directory gives an empty list, not a missing value and I would thus expect &lt;EM&gt;Is Missing()&lt;/EM&gt; to return 0. Strangely, If applied to an empty list &lt;EM&gt;Is Missing()&lt;/EM&gt; returns an empty list, not 0 or 1 that is the expected output from a boolean function. I am not sure how it works in JMP 9.&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="line-height: 1.5em; font-size: 10pt;"&gt;I suggest you use &lt;/SPAN&gt;N Items() instead&lt;SPAN style="line-height: 19px; font-size: 10pt;"&gt;. For example:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 14px; font-family: Courier;"&gt;tt&lt;SPAN style="color: #011993;"&gt;=&lt;/SPAN&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;SPAN style="color: #032ce4;"&gt;nitems&lt;/SPAN&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;_files&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;SPAN style="color: #011993;"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If using &lt;EM&gt;Is Missing()&lt;/EM&gt; you can switch between 0 and 1 with the NOT operator, i.e. !Is Missing()&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 25 Jan 2014 18:38:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Check-to-see-if-a-list-is-empty/m-p/8045#M8039</guid>
      <dc:creator>ms</dc:creator>
      <dc:date>2014-01-25T18:38:44Z</dc:date>
    </item>
    <item>
      <title>Re: Check to see if a list is empty</title>
      <link>https://community.jmp.com/t5/Discussions/Check-to-see-if-a-list-is-empty/m-p/8046#M8040</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;EM&gt;Is Missing()&lt;/EM&gt; on an empty list will return an empty list, because it is operating on each element of a list.&amp;nbsp; If the list is empty, there are no elements for &lt;EM&gt;Is Missing()&lt;/EM&gt; to operate on, so it returns the empty list.&amp;nbsp; However, a better way to see this is the following example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;lst = {1,2,.,""};&lt;/P&gt;&lt;P&gt;ismissing(lst);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jan 2014 01:42:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Check-to-see-if-a-list-is-empty/m-p/8046#M8040</guid>
      <dc:creator>michael_jmp</dc:creator>
      <dc:date>2014-01-29T01:42:22Z</dc:date>
    </item>
  </channel>
</rss>

