<?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 Text to Columns result columns in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Text-to-Columns-result-columns/m-p/210974#M42255</link>
    <description>&lt;P&gt;I'm using the built-in JSL Text to Columns() function. I won't know how many "segments" my input text has, so I won't know in advance how many new columns will result from calling the function. But I need to know this so I can do certain subsequent steps in my script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Back when this was an add-in, Jeff Perkinson's v3 returned a result that gave the names of the columns that had been created; the version that is built in doesn't seem to return anything (?). I installed his v3, but I'm not getting scriptable access to his version of the function. (I'm on JMP 15 EA right now; I haven't diddled around other than trying to call the function in his namespace as described in the v3 docs).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Questions:&lt;/P&gt;&lt;P&gt;1. Assuming I'll use the built-in version of Text to Columns(), what's a good way to get the names of the columns that were created (or at least the *number* of columns that were created).&lt;/P&gt;&lt;P&gt;2. Would it be better to use J.P.'s v3, and if so, how do I make it callable these days.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;John&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 29 May 2019 13:22:13 GMT</pubDate>
    <dc:creator>john_madden</dc:creator>
    <dc:date>2019-05-29T13:22:13Z</dc:date>
    <item>
      <title>Text to Columns result columns</title>
      <link>https://community.jmp.com/t5/Discussions/Text-to-Columns-result-columns/m-p/210974#M42255</link>
      <description>&lt;P&gt;I'm using the built-in JSL Text to Columns() function. I won't know how many "segments" my input text has, so I won't know in advance how many new columns will result from calling the function. But I need to know this so I can do certain subsequent steps in my script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Back when this was an add-in, Jeff Perkinson's v3 returned a result that gave the names of the columns that had been created; the version that is built in doesn't seem to return anything (?). I installed his v3, but I'm not getting scriptable access to his version of the function. (I'm on JMP 15 EA right now; I haven't diddled around other than trying to call the function in his namespace as described in the v3 docs).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Questions:&lt;/P&gt;&lt;P&gt;1. Assuming I'll use the built-in version of Text to Columns(), what's a good way to get the names of the columns that were created (or at least the *number* of columns that were created).&lt;/P&gt;&lt;P&gt;2. Would it be better to use J.P.'s v3, and if so, how do I make it callable these days.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;John&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 13:22:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Text-to-Columns-result-columns/m-p/210974#M42255</guid>
      <dc:creator>john_madden</dc:creator>
      <dc:date>2019-05-29T13:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: Text to Columns result columns</title>
      <link>https://community.jmp.com/t5/Discussions/Text-to-Columns-result-columns/m-p/210985#M42256</link>
      <description>&lt;P&gt;Here is a simple way to get the number of added columns&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = New Table( "Example",
	Add Rows( 2 ),
	New Column( "the text", Character, "Nominal", Set Values( {"A,B,C,D", "X,Y,Z"} ) )
);

nColNow = N Items( dt &amp;lt;&amp;lt; get column names );
dt &amp;lt;&amp;lt; text to columns( delimiter( "," ), columns( :the text ) );
colAdded = N Items( dt &amp;lt;&amp;lt; get column names ) - nColNow;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 May 2019 14:06:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Text-to-Columns-result-columns/m-p/210985#M42256</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2019-05-29T14:06:03Z</dc:date>
    </item>
    <item>
      <title>Re: Text to Columns result columns</title>
      <link>https://community.jmp.com/t5/Discussions/Text-to-Columns-result-columns/m-p/210986#M42257</link>
      <description>I think I might just wrap the built-in Text to Columns() into a user function that adds this functionality in the form of a return value.&lt;BR /&gt;John</description>
      <pubDate>Wed, 29 May 2019 14:32:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Text-to-Columns-result-columns/m-p/210986#M42257</guid>
      <dc:creator>john_madden</dc:creator>
      <dc:date>2019-05-29T14:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: Text to Columns result columns</title>
      <link>https://community.jmp.com/t5/Discussions/Text-to-Columns-result-columns/m-p/211286#M42311</link>
      <description>&lt;P&gt;This works well for me:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Add Custom Functions(
	New Custom Function(
		"my",
		"Text to Columns",
		// Wraps native Text to Columns() to make it return an associative array,
		// containing the split column name(s) split (as keys), and the number of 
		// columns added (as values)
		Function( {columns, delims, table = Current Data Table()},
			// First parameter should be a list, but accept single value without brackets
			If( Not( Is List( columns ) ),
				columns = {columns}
			);
			columns = table &amp;lt;&amp;lt; Get Column Reference( columns );
			If( Not( Is String( delims ) ),
				Throw()
			);
			n_cols = N Items( columns );
			result = Associative Array();
			For( i = 1, i &amp;lt;= n_cols, i++,
				cols_before = N Cols( table );
				Eval( Parse( Eval Insert( "^table^ &amp;lt;&amp;lt; Text to Columns(delimiters(\!"^delims^\!"), columns(^columns[i]^))" ) ) );
				cols_added = N Cols( table ) - cols_before;
				result &amp;lt;&amp;lt; Insert Item( columns[i] &amp;lt;&amp;lt; Get Name, cols_added );
			);
			Return( result);
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;PRE&gt;Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Consumer Preferences.jmp" );
my:Text to Columns({:Brush Delimited, :Floss Delimited}, ",", dt)

["Brush Delimited" =&amp;gt; 4, "Floss Delimited" =&amp;gt; 4]&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2019 19:14:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Text-to-Columns-result-columns/m-p/211286#M42311</guid>
      <dc:creator>john_madden</dc:creator>
      <dc:date>2019-05-30T19:14:30Z</dc:date>
    </item>
  </channel>
</rss>

