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
ReginaHong
Level III

JSL Script Continue Sequence to End of Table

Hi,

 

I am new to JSL script. Can anyone teach me how to write the script for below option, "Continue sequence to end of table". I would like to automate this process. I only able to find script to key in the first three rows as below:

 

dt << New Column("Time","Continuous", Set Values([1,2,3]));

Then not sure how to automate it if I want to Continue sequence to end of table.

 

Pic1.JPG

1 ACCEPTED SOLUTION

Accepted Solutions
Jeff_Perkinson
Community Manager Community Manager

Re: JSL Script Continue Sequence to End of Table

 

JMPScreenSnapz293.pngThere are some functions available interactively that don't have JSL equivalents. Most of these are things that only make sense interactively. In this case, it's assumed that as a JSL author you can create the data you want as you want it. 

 

For the pattern you're looking for you should examine the Row()Count(), and Sequence() functions. 

New Table( "Sequences",
	Add Rows( 20 ),
	New Column( "Row",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula( Row() )
	),
	New Column( "Count",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula( Count( 10, 30, 21, 1 ) )
	),
	New Column( "Sequence",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula( Sequence( 100, 130, 0.5, 2 ) )
	)
);

 

 

 

-Jeff

View solution in original post

2 REPLIES 2
MathStatChem
Level VI

Re: JSL Script Continue Sequence to End of Table

If you just want to fill the column with the sequence 1, 2, ..., you can use this JSL:

dt=Current Data Table();
dt << New Column("ABCD", Numeric, Continuous, Set Values(1::NRows(dt)));

The statement

a::b

,where a and b are integers, creates a vector of sequencial values from a to b, indexed by 1.   More generally, a::b::increment returns [a a+increment a+2*increment ... b].  For example 

2::20::2

returns [2 4 6 8 10 12 14 16 18 20]

 

If you want a script that will contine the sequence based on the selected rows, that would be a little bit more work to create, I think.  

 

Jeff_Perkinson
Community Manager Community Manager

Re: JSL Script Continue Sequence to End of Table

 

JMPScreenSnapz293.pngThere are some functions available interactively that don't have JSL equivalents. Most of these are things that only make sense interactively. In this case, it's assumed that as a JSL author you can create the data you want as you want it. 

 

For the pattern you're looking for you should examine the Row()Count(), and Sequence() functions. 

New Table( "Sequences",
	Add Rows( 20 ),
	New Column( "Row",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula( Row() )
	),
	New Column( "Count",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula( Count( 10, 30, 21, 1 ) )
	),
	New Column( "Sequence",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula( Sequence( 100, 130, 0.5, 2 ) )
	)
);

 

 

 

-Jeff