cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
lwx228
Level VIII

How do I complete the insert column with JSL?

The script index could not be found.Thank you!

For example: insert a two-column numeric format column to the left of column 2.

2018-10-20_18-53-54.png

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How do I complete the insert column with JSL?

You can use "Move Selected Columns()" to move a column that you have added to the end of your data table.  However, just as with the "Add Multiple Columns" the choices are focused on adding after a column.  So you would have to subtract 1 from your position, and then use that value as the insert position

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << New Column("The New Column", set selected)
Wait( 2 );
dt << Move Selected Columns( after(as column(1)) );

// or

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Add Multiple Columns( "Added ", 2, after(as column(1)), numeric );
Jim

View solution in original post

4 REPLIES 4
txnelson
Super User

Re: How do I complete the insert column with JSL?

The "Insert Columns" functionality is handled by  "Add Multiple Columns" .  It is located under "Data Table > Data Table Cols" in the Scripting Index

addcols.PNG 

Jim
lwx228
Level VIII

Re: How do I complete the insert column with JSL?

Okay,Thank Jim! but my point is to insert directly to the left of column 2.
Can I create a new column at the end and move it around with code?
txnelson
Super User

Re: How do I complete the insert column with JSL?

You can use "Move Selected Columns()" to move a column that you have added to the end of your data table.  However, just as with the "Add Multiple Columns" the choices are focused on adding after a column.  So you would have to subtract 1 from your position, and then use that value as the insert position

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << New Column("The New Column", set selected)
Wait( 2 );
dt << Move Selected Columns( after(as column(1)) );

// or

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Add Multiple Columns( "Added ", 2, after(as column(1)), numeric );
Jim
lwx228
Level VIII

Re: How do I complete the insert column with JSL?

Exactly the kind below is needed.
Thank Jim!