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
Ressel
Level VI

Updating column list box using list stored in variable not working as expected. Is this how it is meant to be?

I am trying to correct previous "sins" in a script I wrote by updating it with unambiguous references, so that the script refers to the one table I (want to) tell it to, even though another table may be the current (or an "interfering") table. I've tried to reconstruct the problem below.

 

Names Default To Here( 1 );

// this is the table i want to work with
dt = New Table( "Target table", invisible,
	Add Rows( 3 ),
	New Column( "Name_1",
		Character( 1 ),
		"Nominal",
		Set Values( {"A", "B", "C"} ),
		Set Display Width( 45 )
	),
	New Column( "Name_2",
		Character( 1 ),
		"Nominal",
		Set Values( {"X", "Y", "Z"} ),
		Set Display Width( 45 )
	),
	New Column( "NumericRight",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [1, 2, 3] ),
		Set Display Width( 78 )
	),
	New Column( "NumericAlso",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [7, 8, 9] )
	)
);

dt2 = New Table( "Interfering table", invisible,
	Add Rows( 3 ),
	New Column( "Name_1",
		Character( 1 ),
		"Nominal",
		Set Values( {"D", "E", "F"} ),
		Set Display Width( 45 )
	),
	New Column( "Name_2",
		Character( 1 ),
		"Nominal",
		Set Values( {"U", "V", "W"} ),
		Set Display Width( 45 )
	),
	New Column( "NumericInterference",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [4, 5, 6] )
	),
	New Column( "MoreNumeric",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [7, 8, 9] )
	)
);



// get lists
lstName_1 = Associative Array( dt:Name_1 ) << Get Keys; 
lstName_2 = Associative Array( dt:Name_2 ) << Get Keys; 
colList = dt << Get Column Names( "Numeric" );
	
// window with radio buttons & col list box
New Window( "Select values",
	Show Menu( 0 ),
	Show Toolbars( 0 ), 
	Border Box( Top( 0 ), Bottom( 20 ), Left( 20 ), Right( 10 ),
		H List Box(
			
			Panel Box( "Name_1",
				Radio Box(
					Eval List( lstName_1 )
				) 
			),
			
			Panel Box( "Name_2",
				Radio Box(
					Eval List( lstName_2 )
				)
			),
			
			Panel Box( "Numeric Columns",
				clb = Col List Box(	)
			),
			clb << Append( colList ); // making me cry ...
		)
	)
);

 

What I want to see:

Ressel_1-1697225236072.png

 

What I invariably see if my "target table" is not the current table:

Ressel_0-1697225153301.png

 

What completely confuses me is that when I change the name of dt2:NumericInterference to dt2:NumericRight, I get this result:

Ressel_2-1697225490978.png

 

Why is dt2 not letting my script do the work I want it to do? Why is the name change of a column in dt2 affecting what gets into the column list box? I've tried a few variations of moving the colList variable and also tried wrapping it into Eval List(), without "luck".

 

Searching again in the community I found this Need help with populating Col List Box. If there's another solution, thanks for letting me know. Alternatively, is this how it is meant to be, and if so, what is the meaning of this?

2 ACCEPTED SOLUTIONS

Accepted Solutions
hogi
Level XII

Re: Updating column list box using list stored in variable not working as expected. Is this how it is meant to be?

previous post:
Seems that the col list box just accepts columns from the data table which was "current" when the col list box was created.

If dt2 doesn't contain the respective column, it cannot be added.

 

I guess 

current data table(dt);
	
// window with radio buttons & col list box
New Window( "Select values",

is no option for you?

 

If not, then use

clb = Col List Box( Data Table(dt)	)

to specify which data table should be used for the col list box:

hogi_0-1697230466333.png

 

 

 

View solution in original post

hogi
Level XII

Re: Updating column list box using list stored in variable not working as expected. Is this how it is meant to be?


@Ressel wrote:

@Thierry_S, weirdly and unfortunately, this does not work. 


 

The code is almost correct, but you have to use

clb = Col List Box(Data Table(dt), all, << Set Data Type ("numeric"))

you can also use

clb = Col List Box(all, << Set Data Type ("numeric"), Data Table(dt))

but you should not forget the "indicator" *) Data Table().

As indicated in my previous post (below), according to scripting guide, it has to be 

hogi_0-1697282114050.png

 

Like with the column names, it doesn't matter if you use the name or the reference.

But it has to be Data Table (name or table  reference) and not just the argument without an indicator..

 

This is a bit misleading, because often Data Table(name) can be replaced with a data table reference

 

But here, the Data Table is an optional argument - and therefore, there has to be an indicator  *) such that Jmp knows what it is.

 

*) What is the official name for "indicator"?

 

 

View solution in original post

15 REPLIES 15
Thierry_S
Super User

Re: Updating column list box using list stored in variable not working as expected. Is this how it is meant to be?

Hi,

At first glance, you only need to use the syntax below to get the list of numerical columns from table dt:

clb = Col List Box(dt, all, << Set Data Type ("numeric"))

Also, it is not clear how the line: "clb << append (collist)" could work since the Get Column Names returns a list of Names and not Columns.

Finally, I don't think you can use the Col List Box across multiple tables (Correct me if I am wrong here).

Best,

TS

Thierry R. Sornasse
Ressel
Level VI

Re: Updating column list box using list stored in variable not working as expected. Is this how it is meant to be?

Thanks @Thierry_S , I will try this tomorrow. However, if dt2 is commented out of the script, the Col List Box updates as expected, so it definitely works (see also first screenshot in my original posting).

Ressel
Level VI

Re: Updating column list box using list stored in variable not working as expected. Is this how it is meant to be?

@Thierry_S, weirdly and unfortunately, this does not work. In the script I've initially posted I made the following changes per your proposal:

// this part was revised ...
Panel Box( "Numeric Columns",
	clb = Col List Box(	)
),
clb << Append( colList );   // making me cry ...


// ... to look like this. 
Panel Box( "Numeric Columns",
clb = Col List Box( dt, all, << Set Data Type ( "numeric" ) ) // this adds the numeric columns from dt2. Why???
)

 

This gave the below result, meaning, the numeric columns from dt2 where added to the column list box, whereas what I want are the numeric columns from dt.

Ressel_0-1697280271649.png

 

Still, very useful learning for me. Thank you!

hogi
Level XII

Re: Updating column list box using list stored in variable not working as expected. Is this how it is meant to be?


@Ressel wrote:

@Thierry_S, weirdly and unfortunately, this does not work. 


 

The code is almost correct, but you have to use

clb = Col List Box(Data Table(dt), all, << Set Data Type ("numeric"))

you can also use

clb = Col List Box(all, << Set Data Type ("numeric"), Data Table(dt))

but you should not forget the "indicator" *) Data Table().

As indicated in my previous post (below), according to scripting guide, it has to be 

hogi_0-1697282114050.png

 

Like with the column names, it doesn't matter if you use the name or the reference.

But it has to be Data Table (name or table  reference) and not just the argument without an indicator..

 

This is a bit misleading, because often Data Table(name) can be replaced with a data table reference

 

But here, the Data Table is an optional argument - and therefore, there has to be an indicator  *) such that Jmp knows what it is.

 

*) What is the official name for "indicator"?

 

 

Ressel
Level VI

Re: Updating column list box using list stored in variable not working as expected. Is this how it is meant to be?

hogi
Level XII

Re: Updating column list box using list stored in variable not working as expected. Is this how it is meant to be?

Thank you for the link, @David_Burnham blog contains a nice collection of gems !

 

I just read the part about Column references in the Distribution platform.

 

Interesting - according to the scripting index it is: 

hogi_0-1697353652002.png

As there are no "< >"  around the Column() argument, one could think  that Column() is the one, non-optional argument

- does it use the Column() function to generate a column reference?

 

But actually it is the same as Data Table() in the previous discussion:

Column()is an indicator for an optional argument:

  • it can be placed everywhere & can be omitted
  • it accepts a column or a list of >=1 columns (as reference or name) - clear sign that this is NOT the column() function

 

I found another entry in the Scripting Index where the dots before and after the Columns() argument indicate that the argument is optional.
Here, it is Columns [plural]  - like in the GUI. Y is another alias. Both help to be not distracted by the function Column().
hogi_1-1697353727842.png

 

Distribution(Column("height"));

Distribution(:height); // doesn't work

Distribution(Columns("name", :sex)); // accepts >=1 arguments; column references and names
Distribution(Columns({"name", :sex})); // accepts lists
Distribution(Continuous Distribution(Column( :height ))); // Distribution can be used without a Column() argument
Distribution("dummy 1st entry", Columns("height")); // Column at non-first position -> works

Distribution("hello"); // not necessary to provide a meaningful (first) argument

Distribution(Columns("name")); // alias
Distribution(Y("name"));
  // alias

 

jthi
Super User

Re: Updating column list box using list stored in variable not working as expected. Is this how it is meant to be?

Scripting Guide does provide some explanation on the terminology Scripting Guide > Introduction to Writing JSL Scripts > JSL Terminology

-Jarmo
hogi
Level XII

Re: Updating column list box using list stored in variable not working as expected. Is this how it is meant to be?

hogi_0-1697379600868.png
So the terminology is named arguments
- and named arguments are always optional - with and without < > in the Scripting Index

 

Unfortunately, not explicitly noted :
then the official name of the "indicator" of a named argument is "name" ?

jthi
Super User

Re: Updating column list box using list stored in variable not working as expected. Is this how it is meant to be?

Official name? Indicator? 

Scripting Guide > JSL Building Blocks > JSL Syntax Rules > JSL Rules for Names 

In JSL, a name is simply something to call an item. When you assign the numeric value 3 to a variable in the expression a = 3, a is a name.


 

-Jarmo