BookmarkSubscribeRSS Feed

select current data table

jojo

Community Trekker

Joined:

Oct 19, 2015

Hello,

I am using a small jmp_addin to add spec limits info to selected columns.  Anyways, the problem I run into is that whenever I run it, it always grabs the latest data table that was open, even if I am running the addin from a different window...is there a way to highlight to the jmp_addin that I am trying to run script from the selected data table?  I thought currentdatatable would do this, but again it seems it always works on latest data table open, and sometimes I need to change/add specs to an already open table...

 

Thanks in advance!

 

 

dt = currentdatatable();
table=list("Spec1", "Spec2", "Spec3" );
r = Column Dialog(
Spec = Col List( "Columns to add Spec" ),
v list ("Select Product Spec Table", rb = Combo Box( table()))
);
 
dtedc = open("C:\myData\ADDIN\Spec Limit\"||table[r["rb"]]||".jmp",invisible);
 
for ( i=1, i<=N Items(r["Spec"]),i++,
for (j=1, j<= nrows(dtedc), j++,
if(as Name(r["Spec"]) == as Name(dtedc:Parameter),
 
  Eval(
  Substitute(
  Expr(
Column(dt, r["Spec"]) << set property("spec limits",
  {LSL( l), Target( t ), USL( u ), Show Limits(1)}
  )
  ),
  Expr( l ), dtedc:LSL,
  Expr( t ), dtedc:Target,
  Expr( u ), dtedc:USL
  )
 
);
 
  );
);
);
 
close(dtedc, nosave);

 

1 ACCEPTED SOLUTION

Accepted Solutions
Jeff_Perkinson

Community Manager

Joined:

Jun 23, 2011

Solution

I just came across this old question that, unfortunately, never got a response.

 

Current Data Table() should return a reference to the active data table window. I'm not sure why it isn't in your case.

 

However, a more reliable method is to prompt the user to choose from the open data tables.

 

Here's a small function that prompts with a list of data tables and returns the choice made by the user.

choose_data_table=function({},
list = {};

For( i = 1, i <= N Table(), i++,
	list[i] = Data Table( i ) << get name
);

win = New Window( "Select a data table", << Modal,
	hb = H List Box(
		Panel Box( "Choose a data table",
			dt = List Box(
				list,
				max selected( 1 ),
				chosen = Data Table( (dt << get selected)[1] );
				show (chosen);
			)
		),

	)
);
chosen);

Use it like this:

dt=choose_data_table(); 
show(dt);

 

-Jeff
1 REPLY
Jeff_Perkinson

Community Manager

Joined:

Jun 23, 2011

Solution

I just came across this old question that, unfortunately, never got a response.

 

Current Data Table() should return a reference to the active data table window. I'm not sure why it isn't in your case.

 

However, a more reliable method is to prompt the user to choose from the open data tables.

 

Here's a small function that prompts with a list of data tables and returns the choice made by the user.

choose_data_table=function({},
list = {};

For( i = 1, i <= N Table(), i++,
	list[i] = Data Table( i ) << get name
);

win = New Window( "Select a data table", << Modal,
	hb = H List Box(
		Panel Box( "Choose a data table",
			dt = List Box(
				list,
				max selected( 1 ),
				chosen = Data Table( (dt << get selected)[1] );
				show (chosen);
			)
		),

	)
);
chosen);

Use it like this:

dt=choose_data_table(); 
show(dt);

 

-Jeff