<?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: Insert contents of variable/expression rather than variable name into New Script in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Insert-contents-of-variable-expression-rather-than-variable-name/m-p/607543#M80914</link>
    <description>&lt;P&gt;Here is a good starting point &lt;LI-MESSAGE title="Expression Handling Functions: Part I - Unraveling the Expr(), NameExpr(), Eval(), ... Conundrum" uid="28963" url="https://community.jmp.com/t5/JMPer-Cable/Expression-Handling-Functions-Part-I-Unraveling-the-Expr/m-p/28963#U28963" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-blog-thread lia-fa-icon lia-fa-blog lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt; on JMP expressions&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is also some info  &lt;A href="https://www.jmp.com/support/help/en/17.0/#page/jmp/advanced-expressions-macros-and-lists.shtml#ww339382" target="_self"&gt; Scripting Guide &amp;gt; Programming Methods &amp;gt; Advanced Expressions&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;JSL Cookbook also might have some topics which include expression handling&lt;LI-MESSAGE title="Run a Platform without Knowing the Number or Names of Columns" uid="464407" url="https://community.jmp.com/t5/JSL-Cookbook/Run-a-Platform-without-Knowing-the-Number-or-Names-of-Columns/m-p/464407#U464407" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-tkb-thread lia-fa-icon lia-fa-tkb lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt; and this one includes good hint for success: Expression handling is a difficult topic. The more example you see, the more you should understand.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 02 Mar 2023 19:26:37 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2023-03-02T19:26:37Z</dc:date>
    <item>
      <title>Insert contents of variable/expression rather than variable name into New Script</title>
      <link>https://community.jmp.com/t5/Discussions/Insert-contents-of-variable-expression-rather-than-variable-name/m-p/607415#M80897</link>
      <description>&lt;P&gt;It would be convenient to be able to assign an expression to a variable and then use that variable to insert the expression into a data table script using New Script.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = New Table("test dt");
anExpr = Expr(
	Show("Hello world.")
);
dt &amp;lt;&amp;lt; New Script("hello world", anExpr);
Show(dt &amp;lt;&amp;lt; Get Property("hello world"));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, when I try this, the script's content is only the variable name.&amp;nbsp; It works if you run it in this state, but if you save the data table and load it again later, the contents of the variable &lt;FONT face="courier new,courier"&gt;anExpr&lt;/FONT&gt; are lost and the table script won't work.&lt;/P&gt;&lt;P&gt;Is there a way to insert the &lt;EM&gt;contents&lt;/EM&gt; of the variable into a table script rather than the variable name?&amp;nbsp; Perhaps it can be done with Substitute, Eval Expr, etc, but I tried quite a few combinations of such methods without success.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2023 16:32:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Insert-contents-of-variable-expression-rather-than-variable-name/m-p/607415#M80897</guid>
      <dc:creator>austinspencer</dc:creator>
      <dc:date>2023-06-08T16:32:06Z</dc:date>
    </item>
    <item>
      <title>Re: Insert contents of variable/expression rather than variable name into New Script</title>
      <link>https://community.jmp.com/t5/Discussions/Insert-contents-of-variable-expression-rather-than-variable-name/m-p/607438#M80901</link>
      <description>&lt;P&gt;JMP made the decision, a long time ago, to be friendly for the common case of an explicit script to be added. That makes the uncommon case, a script in a variable, a bit harder.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = New Table("test dt");
anExpr = Expr(
	Show("Hello world.")
);
// &amp;lt;&amp;lt;NewScript assumes you'll be adding a script that should not be executed. In your
// example the script is a single variable name that will be kept for later. Not its content.
// below,
// evalexpr(...) finds expr(...) and replaces it with its value. (it evaluates nameexpr(anExpr) .)
// nameexpr(...) evaluates by returning the expression in anExpr, without evaluating it. (show(...) does not run at this time.)
// eval(...) runs the newScript method with all the changes made.
eval(evalexpr(dt &amp;lt;&amp;lt; New Script("hello world", expr(nameexpr(anExpr)))));
Show(dt &amp;lt;&amp;lt; Get Property("hello world"));
//
// dt &amp;lt;&amp;lt; Get Property("hello world") = Show("Hello world.");
//&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 15:44:41 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Insert-contents-of-variable-expression-rather-than-variable-name/m-p/607438#M80901</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2023-03-02T15:44:41Z</dc:date>
    </item>
    <item>
      <title>Re: Insert contents of variable/expression rather than variable name into New Script</title>
      <link>https://community.jmp.com/t5/Discussions/Insert-contents-of-variable-expression-rather-than-variable-name/m-p/607441#M80902</link>
      <description>&lt;P&gt;Well, after trying a few more combinations, I found a way that seems like it works.&amp;nbsp; However, I have no idea how or why.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = New Table("test dt");
anExpr = Expr(
	Show("Hello world.")
);
Eval(Eval Expr(
	dt &amp;lt;&amp;lt; New Script("hello world", Expr(Name Expr(anExpr)))
));
Show(dt &amp;lt;&amp;lt; Get Property("hello world"));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P class="lia-indent-padding-left-30px"&gt;*Credit to &lt;A href="https://community.jmp.com/t5/Discussions/Add-Contents-of-script-file-as-New-Script-to-data-table/m-p/578407/highlight/true#M78580" target="_self"&gt;this answer&lt;/A&gt; for getting me close.&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone has any insight into this, I'd be curious to know more.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 15:52:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Insert-contents-of-variable-expression-rather-than-variable-name/m-p/607441#M80902</guid>
      <dc:creator>austinspencer</dc:creator>
      <dc:date>2023-03-02T15:52:51Z</dc:date>
    </item>
    <item>
      <title>Re: Insert contents of variable/expression rather than variable name into New Script</title>
      <link>https://community.jmp.com/t5/Discussions/Insert-contents-of-variable-expression-rather-than-variable-name/m-p/607455#M80904</link>
      <description>&lt;P&gt;There are of course a few ways to do this, here are two:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = new table();

//one way
scriptExpr = expr ( print( "hi there" ) );
eval ( substitute ( 
	expr ( dt &amp;lt;&amp;lt; new script ("greeting 1", _x_  ) ),
	expr( _x_ ), 
	nameexpr( scriptExpr ) 
) );

// another way
scriptQuote = jslquote ( print ( "hi there" ) );
eval( evalexpr(
	dt &amp;lt;&amp;lt; new script ("greeting 2", expr( parse( scriptQuote ) ) ) 
) ) ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Brady&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 15:55:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Insert-contents-of-variable-expression-rather-than-variable-name/m-p/607455#M80904</guid>
      <dc:creator>brady_brady</dc:creator>
      <dc:date>2023-03-02T15:55:35Z</dc:date>
    </item>
    <item>
      <title>Re: Insert contents of variable/expression rather than variable name into New Script</title>
      <link>https://community.jmp.com/t5/Discussions/Insert-contents-of-variable-expression-rather-than-variable-name/m-p/607543#M80914</link>
      <description>&lt;P&gt;Here is a good starting point &lt;LI-MESSAGE title="Expression Handling Functions: Part I - Unraveling the Expr(), NameExpr(), Eval(), ... Conundrum" uid="28963" url="https://community.jmp.com/t5/JMPer-Cable/Expression-Handling-Functions-Part-I-Unraveling-the-Expr/m-p/28963#U28963" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-blog-thread lia-fa-icon lia-fa-blog lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt; on JMP expressions&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is also some info  &lt;A href="https://www.jmp.com/support/help/en/17.0/#page/jmp/advanced-expressions-macros-and-lists.shtml#ww339382" target="_self"&gt; Scripting Guide &amp;gt; Programming Methods &amp;gt; Advanced Expressions&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;JSL Cookbook also might have some topics which include expression handling&lt;LI-MESSAGE title="Run a Platform without Knowing the Number or Names of Columns" uid="464407" url="https://community.jmp.com/t5/JSL-Cookbook/Run-a-Platform-without-Knowing-the-Number-or-Names-of-Columns/m-p/464407#U464407" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-tkb-thread lia-fa-icon lia-fa-tkb lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt; and this one includes good hint for success: Expression handling is a difficult topic. The more example you see, the more you should understand.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 19:26:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Insert-contents-of-variable-expression-rather-than-variable-name/m-p/607543#M80914</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-03-02T19:26:37Z</dc:date>
    </item>
  </channel>
</rss>

