<?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: Pass Empty Variables to Funciton in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Pass-Empty-Variables-to-Function/m-p/35674#M21042</link>
    <description>&lt;P&gt;Yeah, I was trying to use it for Case 1. &amp;nbsp;I was building a tool that took advantage a user config file. &amp;nbsp;Since variables are loaded from the file that's user defined, they may or may not exist and may or may not be set to true/false. &amp;nbsp;I was hoping to just build a wrapper function that would test this until I realized a could do an "or" statement since it exits once it hits a truthy.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;if(isempty(var) | !var,
  //run code)
);

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This doesn't error out b/c if the variable hasn't been declared yet it will signal a Truthy and move on to run the code in the if statement w/o checking the other dependencies. &amp;nbsp;If the variable has been defined then I can check if it's true or not.&lt;/P&gt;</description>
    <pubDate>Fri, 10 Feb 2017 23:25:46 GMT</pubDate>
    <dc:creator>msharp</dc:creator>
    <dc:date>2017-02-10T23:25:46Z</dc:date>
    <item>
      <title>Pass Empty Variables to Function</title>
      <link>https://community.jmp.com/t5/Discussions/Pass-Empty-Variables-to-Function/m-p/35664#M21035</link>
      <description>&lt;P&gt;The below code doesn't work, b/c JSL evaluates emptyVar when you try to pass it to the function instead of evaluating it on run time w/in the function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;isEmptyTest = Function({var},
	return(isempty(var));
);
isEmptyTest(emptyVar);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It would be awesome if this was changed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2017 19:45:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Pass-Empty-Variables-to-Function/m-p/35664#M21035</guid>
      <dc:creator>msharp</dc:creator>
      <dc:date>2017-02-10T19:45:42Z</dc:date>
    </item>
    <item>
      <title>Re: Pass Empty Variables to Funciton</title>
      <link>https://community.jmp.com/t5/Discussions/Pass-Empty-Variables-to-Function/m-p/35671#M21040</link>
      <description>&lt;P&gt;A symbol table keeps track of all the variables that have ever been &lt;EM&gt;&lt;STRONG&gt;set&lt;/STRONG&gt; &lt;/EM&gt;to a value. If a variable has never been set, it is uninitialized, and using it is probably an error.&lt;/P&gt;
&lt;P&gt;The builtin &lt;STRONG&gt;&lt;EM&gt;isEmpty()&lt;/EM&gt;&lt;/STRONG&gt; function makes special cases out of several unusual situations.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Case 1&lt;/STRONG&gt;: variable never used before&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Is Empty(neverSeenBefore) = 1;&lt;BR /&gt;&lt;BR /&gt;print(neverSeenBefore)&lt;BR /&gt;/*:&lt;BR /&gt;Name Unresolved: neverSeenBefore in access or evaluation of 'neverSeenBefore' , neverSeenBefore/*###*/&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Name Unresolved&lt;/EM&gt; means JMP looked in the symbol table and could not locate the name.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Case 2&lt;/STRONG&gt; (normal case): variable set to the value returned by the builtin &lt;EM&gt;&lt;STRONG&gt;empty()&lt;/STRONG&gt;&lt;/EM&gt; function, or another function that returned empty()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ev=empty(); show(isempty(ev),ev);
/*:
Is Empty(ev) = 1;
ev = Empty();&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you expect to test for empty, you should use the &lt;STRONG&gt;&lt;EM&gt;empty()&lt;/EM&gt;&lt;/STRONG&gt; function to initialize your variables.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Case 3&lt;/STRONG&gt;: variable cleared by the builtin &lt;EM&gt;&lt;STRONG&gt;clear globals()&lt;/STRONG&gt;&lt;/EM&gt; function&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ev2=42; clear globals(ev2); show(isempty(ev2),ev2);
Is Empty(ev2) = 1;
ev2 = ev2;&lt;/PRE&gt;
&lt;P&gt;Using &lt;EM&gt;&lt;STRONG&gt;clear globals()&lt;/STRONG&gt;&lt;/EM&gt; isn't a good idea in production code, but can be helpful while developing code. It does NOT remove the symbol from the symbol table but does remove its value, not even leaving empty() for the value. It may act like empty() or missing, depending how it is used.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;JSL passes arguments to user written functions by value, making a copy for the function to use. A future version of JMP may allow passing arguments by reference. We'll see what happens with passing uninitialized variables by reference at that point.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2017 20:47:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Pass-Empty-Variables-to-Function/m-p/35671#M21040</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2017-02-10T20:47:24Z</dc:date>
    </item>
    <item>
      <title>Re: Pass Empty Variables to Funciton</title>
      <link>https://community.jmp.com/t5/Discussions/Pass-Empty-Variables-to-Function/m-p/35674#M21042</link>
      <description>&lt;P&gt;Yeah, I was trying to use it for Case 1. &amp;nbsp;I was building a tool that took advantage a user config file. &amp;nbsp;Since variables are loaded from the file that's user defined, they may or may not exist and may or may not be set to true/false. &amp;nbsp;I was hoping to just build a wrapper function that would test this until I realized a could do an "or" statement since it exits once it hits a truthy.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;if(isempty(var) | !var,
  //run code)
);

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This doesn't error out b/c if the variable hasn't been declared yet it will signal a Truthy and move on to run the code in the if statement w/o checking the other dependencies. &amp;nbsp;If the variable has been defined then I can check if it's true or not.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2017 23:25:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Pass-Empty-Variables-to-Function/m-p/35674#M21042</guid>
      <dc:creator>msharp</dc:creator>
      <dc:date>2017-02-10T23:25:46Z</dc:date>
    </item>
  </channel>
</rss>

