This works well for me:
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 << Get Column Reference( columns );
If( Not( Is String( delims ) ),
Throw()
);
n_cols = N Items( columns );
result = Associative Array();
For( i = 1, i <= n_cols, i++,
cols_before = N Cols( table );
Eval( Parse( Eval Insert( "^table^ << Text to Columns(delimiters(\!"^delims^\!"), columns(^columns[i]^))" ) ) );
cols_added = N Cols( table ) - cols_before;
result << Insert Item( columns[i] << Get Name, cols_added );
);
Return( result);
)
)
);
Example:
Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Consumer Preferences.jmp" );
my:Text to Columns({:Brush Delimited, :Floss Delimited}, ",", dt)
["Brush Delimited" => 4, "Floss Delimited" => 4]