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

Extract the data from data table

hi, all
I now need to create the tabs which is based on my data table(i named as dt2). The names of the tabs is based on the dt2, meant here: if dt2 has 10 products name, so in my interface i also need have 10 tabs which is based on the product names in dt2.
One of my requirement is i cannot hardcode the coding, because in the future, maybe i need to add in the name of products in dt2, so the tabs will auto have same with the number of products name in dt2.

So, how to pull the data from dt2 and make it as tabs?
Actually i don't know how to write the code for the task that i need complete, i have try many times, but its keep runs out errors.

Thanks.

 

                                   dt2

photo 1.png

 

dt2 = Data Table(
	"Data Table........") << Summary( 
	Group( :F D ), 
	Freq( "None" ), 
	Weight( "None" ),
	invisible	
	);   


//Create Tabs based on the F D
VariabilityWindow = New Window("Variability Chart",tb = Tab Box() );

For(i =1, i <=nTabs(dt2 << get row names()), i++,
	tb << insert(
		dt2: F D[i] || Char(i),
		V list Box(
			Button Box("Variability Chart #" || Char(i)),
		)
		
	)
	);
1 REPLY 1
txnelson
Super User

Re: Extract the data from data table

It is obvious that you are still struggling with the very basic parts of JSL.  A couple of pointers, based upon the code you are showing.

1.  Don't make up code.  When it doesn't work, it is just confusing.  When guessing at code works, you don't know why, and you haven't learned anything.

2. Use the Log.  In your many discussions that you have listed, I have not seen results from the log.  These messages provide great detail and insight on what is going wrong with your JSL.

3. Use Help==>Scripting Index. It provides the correct syntax and examples on how the items work.  The Scripting Index is the most complete documentation on JSL.

 

Let me critique your code

dt2 = Data Table(
	"Data Table........") << Summary( 
	Group( :F D ), 
	Freq( "None" ), 
	Weight( "None" ),
	invisible	
	);   

The description of the Summary Platform is found at:

Help==Scripting Index==>Data Table==>Summary

summary doc.PNG

Here is an example almost itdentical to what is needed.

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Summary( Group( :Age ), Mean( :Height ) );

But what seems to be missing is how to create a pointer to the summary table that will be produced by the Summary Platform.  However, you don't seem to understand how to reference data tables.  In the example, the variable "dt" points to the data table opened.  So as can be seen it is used when the Summary Platform references it.  However, you can also use a Data Table() function to point to the physical name of a data table.  Which is kind of what I think you are trying to do, with Data Table("Data Table.............").  Either one will work.......if you know the name of the data table.  But as you are showing in your provided code, make sure you specify a variable to point to the data table you will be creating from the Summary Platform, so you can use it in your next step ( i.e. dt = )

 

The next section of code appears that you were just guessing at syntax.  

//Create Tabs based on the F D
VariabilityWindow = New Window("Variability Chart",tb = Tab Box() );

For(i =1, i <=nTabs(dt2 << get row names()), i++,
	tb << insert(
		dt2: F D[i] || Char(i),
		V list Box(
			Button Box("Variability Chart #" || Char(i)),
		)
		
	)
	);

What you are trying to do is to generate a new tab for each Value of F D from the summary data table.

A search of the Scripting Index shows that nothing by the name of nTabs or get row names() exists.  I assume you were thinking that nTabs would give you the number of tabls you want.  Which it cannot, since at this point in the program, no tabls have been produced, and just because a summary table has been produced, it would have know idea that the number of rows in the data table are the number of tabs you want to product.  However, you can look into the Scripting Index and see what functions will tell you the number of rows there are in a data table "N Rows()" and simply change the made up code for N Rows() and you will have your solution

 

The following code is making the assumption that your original data table has a pointer variable called "dt" that is pointing to it.

dt2 = dt << Summary( Group( :F D ), Freq( "None" ), Weight( "None" ), invisible );   


//Create Tabs based on the F D
VariabilityWindow = New Window( "Variability Chart", tb = Tab Box() );

For( i = 1, i <= nrows( dt2 ), i++,
	tb << Insert(
		dt2:F D[i] || Char( i ),
		V List Box( Button Box( "Variability Chart #" || Char( i ) ), )
		
	)
);



dt2 = Data Table(
	"Data Table........") << Summary( 
	Group( :F D ), 
	Freq( "None" ), 
	Weight( "None" ),
	invisible	
	); 
Jim