cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
Thomas1
Level V

Select specific columns with JSL name contains code

The Name contains script:

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
New Window( "Filter Col Selector Example",
    fontobj = lb = Filter Col Selector( width( 250 ) )
);
lb << Name contains( "a" );

 

delviers all colums, which contains a. What code must be added in order to mark one of these columns by clicking or double clikking the column from the list box?

 

23 REPLIES 23
gzmorgan0
Super User (Alumni)

Re: Select specific columns with JSL name contains code

What version of JMP are you using.

 

When I run the script I sent, here is what happens:

  • the dialog appears with the filter box
  • type in a, then select age, age is highlighted; select name then name is selected; hold the control key and select age and both are selected.
  • delete a and type in ei then weight and height are selected, similar behavior as above.

Sorry it is not working for you.  The script I sent works on JMP 14.1 on the PC. It does not work in JMP 13.2.1, before I look for an alternative, which version of JMP are you using?

 

Anytime you ask a question you should always specify the version of JMP you are using.

 

 

 

gzmorgan0
Super User (Alumni)

Re: Select specific columns with JSL name contains code

This script works in JMP 12 and JMP 13. The reason the previous script does not work in earlier versions of JMP is that the data table messages clear column selections and select columns(list)  are not available. In earlier versions, columns need to be selected and unselected one at a time, hence, the required changes below. I do not have access to any version earlier than JMP 12.

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );


New Window( "Filter Col Selector Example",
    fcb = Filter Col Selector( width( 250 ))
);

ib = (fcb<<Parent) << Xpath("//IfBox");
ib << set(1);
lbb = (fcb<<Parent) << Xpath("(//ListBoxBox)[1]");

lbb << set Function(Function({this},{_xx, i},
   selCol = this<<get selected;
   _xx = dt << get selected columns;
   For(i=1, i<=nitems(_xx), i++, _xx[i] << set selected(0));
   For(i=1, i<=nitems(selCol), i++, column(dt,selCol[i] ) << set selected(1));
  )	
);

 

Thomas1
Level V

Re: Select specific columns with JSL name contains code

Great. Now the JSL is working with JMP 13.1 . I appreciate really your and Ian's endurance in geting the question solved.

Thanks a lot

Thomas1
Level V

Re: Select specific columns with JSL name contains code

The JSL is now working with the satrting JSL:

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

If the JSL is generalized (to use it in an Icon Toolbar) in JMP 13.1.0 like:

Names Default To Here( 1 );
dt = Current Data Table();

I run into to the old problem => No colums selection. Do you know whether this specific for JMP 13.10.0?

If yes, don't try to fix it. I hope that I will have JMP 14 soon.

gzmorgan0
Super User (Alumni)

Re: Select specific columns with JSL name contains code

The last script I sent (modified for Current Data Table ) works for both JMP 12 and JMP 13. Here is a screen shot from JMP 12. As the screen shot depicts this is the JMP sample data table.   

However, the script will not work if the current data table changes because << Get Selected Columns, returns a list of column references, not the table name.  So :Chloroform will return an error if the current data table does not have that column.  So to make the script more robust, I changed line 18 below to the JSL below.  The script is attached.  It should even if the original table is no longer the current data table. However, if the script (Here) changes the value of dt while the dialog is still open, then a a name collision will occur and cause a problem. Or if the original table is closed when the dialog is still open, problems will occur.

   For(i=1, i<=nitems(_xx), i++, column(dt, char(_xx[i])) << set selected(0));

 

image.png

Thomas1
Level V

Re: Select specific columns with JSL name contains code

Again thanks for your support and patience.

The script is better, but as already mentioned, it is still possible to get no function. For example after the dialog has been closed (via Icon in the tool bar) and rum again for a second search and select run on the same data table. Maybe things will improve with JMP 14.

gzmorgan0
Super User (Alumni)

Re: Select specific columns with JSL name contains code

I do not know what you mean by "after the dialog has been closed (via Icon in the tool bar) ".

 

Which icon? Is thid a custom script?

 

When you have a script that runs, but does not run in different conditions, most of the time it is a scoping problem.  For example the first script I gave you for JMP13 and 12 worked, however, if the current data table changed while the dialog was still open, the syntax :colname will not work. It was a weakness in my program. However, when I converted the :colname to a string "colname" using the char() function and referencing the source table it is robust.

 

So whatever you are doing via the icon or following script is creating a scoping problem and a JMP version will not fix the problem.  So since you have not shared what you are doing, I can only point to some things  to look for:

  • The script must use names default to here, if you have other scripts that reference dt.
  • Make sure the original target table is the current table before you click on the script button again. (Menu bar displays the table list).   

I think you might have a scoping problem, or a table locking problem. Good luck finding it. 

 

Here is a screenshot, I added the script as an addin. I used this many times while doing other stuff, using it on different tables then using again and it works the same in both JMP 13 and JMP 12.  It is not a version issue.

image.png

Thomas1
Level V

Re: Select specific columns with JSL name contains code

You are right. Your code is working. My mistake was the naming of the icon. I did not use a blank.Screenshot2.JPG

After the icon name has been changed to "Column Search" it is working perfectly.

A last question to this topic would be what code must be added to script in order not only to select the found column, but also to go to the found column?

This would improve the whole process further in case the column is not in the visible part of the window.

 

Thomas1
Level V

Re: Select specific columns with JSL name contains code

Sorry for that. I do have JMP 13.1

gzmorgan0
Super User (Alumni)

Re: Select specific columns with JSL name contains code

 

 

JMP 13.2.1 has  dt << Go To (col ref) ;  I don't have 13.1. So, here is a test case. If this works teh modified script is attached. it added JSL to Bring Window to Front(), and Go To()

 

Names Default to Here(1);
 dt = open("$Sample_Data/Semiconductor Capability.jmp");
 //select a column towards the end of the table
:PM_L1 << set selected(1);
wait(2);
dt << go to(:PM_L1);