cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
dlemieu1
Level II

Add Rows question

Hello,

 

New JSL scripter here. Trying to get 5 new rows added after every existing row, 25 rows in the data table. No issues while debugging, i changes from 25 to 1 in increments of 1 as expected, but no new rows are added to my data table at any point during/after the For loop. Not sure what I'm doing wrong, any help would be appreciated!

dt=current data table();

For(i=N Rows(dt),i>=1, i--,
	dt << Add Rows( 5, i ); 
);

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Craige_Hales
Super User

Re: Add Rows question

I've never used the 2-argument form, but the scripting index shows this example, using a keyword to specify the meaning of the 2nd arg

dt << Add Rows( 3, after( 5 ) );
Craige

View solution in original post

txnelson
Super User

Re: Add Rows question

I am a bit confused.  Given the below table

expand1.PNG

Your script creates

expand2.PNG

Which is what my understanding is what you want.

Here is my script, using your code that creates the above data table and it's expansion

Names Default To Here( 1 );
// Create a table with 25 rows
dt = New Table( "Example",
	Add Rows( 25 ),
	New Script( "Source", Data Table( "Untitled 97" ) << Subset( All rows, Selected columns only( 0 ) ) ),
	New Column( "Column 1",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
		)
	)
);

Wait( 5 );
// Now create the new rows

For( i = N Rows( dt ), i >= 1, i--,
	dt << Add Rows( 5, i )
);
Jim

View solution in original post

3 REPLIES 3
Craige_Hales
Super User

Re: Add Rows question

I've never used the 2-argument form, but the scripting index shows this example, using a keyword to specify the meaning of the 2nd arg

dt << Add Rows( 3, after( 5 ) );
Craige
txnelson
Super User

Re: Add Rows question

I am a bit confused.  Given the below table

expand1.PNG

Your script creates

expand2.PNG

Which is what my understanding is what you want.

Here is my script, using your code that creates the above data table and it's expansion

Names Default To Here( 1 );
// Create a table with 25 rows
dt = New Table( "Example",
	Add Rows( 25 ),
	New Script( "Source", Data Table( "Untitled 97" ) << Subset( All rows, Selected columns only( 0 ) ) ),
	New Column( "Column 1",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
		)
	)
);

Wait( 5 );
// Now create the new rows

For( i = N Rows( dt ), i >= 1, i--,
	dt << Add Rows( 5, i )
);
Jim
dlemieu1
Level II

Re: Add Rows question

I think this was a simple case of "close it and open it again". My data table must have gotten corrupted somehow because when I closed and reopened it, my code worked fine. Sorry for any inconvenience.