<?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 script to add two column in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/script-to-add-two-column/m-p/354331#M60416</link>
    <description>&lt;P&gt;i am trying to add two columns.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;two of the column has name abcd and efgh&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;following line works:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt_tab &amp;lt;&amp;lt; New Column( newcolumn, formula( :name( "abcd" ) + :name( "efgh" ) ) );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but following code is throwing an error&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;name1 = "abcd";
name2 ="efgh";

dt_tab &amp;lt;&amp;lt; New Column( name1 || "3", formula(:name(name1) + :name(name2)));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;why is the 2nd method not working?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2023 22:04:43 GMT</pubDate>
    <dc:creator>tangxu</dc:creator>
    <dc:date>2023-06-09T22:04:43Z</dc:date>
    <item>
      <title>script to add two column</title>
      <link>https://community.jmp.com/t5/Discussions/script-to-add-two-column/m-p/354331#M60416</link>
      <description>&lt;P&gt;i am trying to add two columns.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;two of the column has name abcd and efgh&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;following line works:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt_tab &amp;lt;&amp;lt; New Column( newcolumn, formula( :name( "abcd" ) + :name( "efgh" ) ) );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but following code is throwing an error&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;name1 = "abcd";
name2 ="efgh";

dt_tab &amp;lt;&amp;lt; New Column( name1 || "3", formula(:name(name1) + :name(name2)));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;why is the 2nd method not working?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 22:04:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/script-to-add-two-column/m-p/354331#M60416</guid>
      <dc:creator>tangxu</dc:creator>
      <dc:date>2023-06-09T22:04:43Z</dc:date>
    </item>
    <item>
      <title>Re: script to add two column</title>
      <link>https://community.jmp.com/t5/Discussions/script-to-add-two-column/m-p/354336#M60418</link>
      <description>&lt;P&gt;The reason this is not working, is that neither the :Name() function nor the Formula() element does not parse the contents of the function before execution.&amp;nbsp; You need to create the exact JSL before execution&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;name1 = "abcd";
name2 = "efgh";

Eval(
	Substitute(
			Expr(
				dt_tab &amp;lt;&amp;lt; New Column( name1 || "3",
					formula( Column( __name1__ ) ) + Column( __name2__ )
				)
			),
		Expr( __name1__ ), name1,
		Expr( __name2__ ), name2
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Feb 2021 03:09:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/script-to-add-two-column/m-p/354336#M60418</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-02-01T03:09:19Z</dc:date>
    </item>
    <item>
      <title>Re: script to add two column</title>
      <link>https://community.jmp.com/t5/Discussions/script-to-add-two-column/m-p/354346#M60419</link>
      <description>&lt;P&gt;Thank you Jim. I tried this but still not working.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Feb 2021 04:56:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/script-to-add-two-column/m-p/354346#M60419</guid>
      <dc:creator>tangxu</dc:creator>
      <dc:date>2021-02-01T04:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: script to add two column</title>
      <link>https://community.jmp.com/t5/Discussions/script-to-add-two-column/m-p/354355#M60422</link>
      <description>&lt;P&gt;My error......I had placed an ")" wrong, and should have used the As Column() function, not the Column() function&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt_tab = New Table( "Example",
	Add Rows( 4 ),
	New Column( "abcd", 

		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [1, 2, 3, 4] )
	),
	New Column( "efgh",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [5, 6, 7, 8] )
	)
);

name1 = "abcd";
name2 = "efgh";

Eval(
	Substitute(
			Expr(
				dt_tab &amp;lt;&amp;lt;
				New Column( name1 || "3",
					formula(
						As Column( __name1__ )
						+As Column( __name2__ )
					)
				)
			),
		Expr( __name1__ ), name1,
		Expr( __name2__ ), name2
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Feb 2021 05:13:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/script-to-add-two-column/m-p/354355#M60422</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-02-01T05:13:25Z</dc:date>
    </item>
  </channel>
</rss>

