cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
rshehadah
Level I

Show a pop up with a statement

Hi,

 

I am new to JSL scripting and was wondering how can I get JMP to pop up a window to display how many cols were deleted.

 

My code to delete cols is shown below:

dt = Current Data Table();

For( i = N Col( dt ), i >= 1, i--,

         If( (Col N Missing( Column( i ) ) / N Row()) == 1,

              dt << delete columns( i )

)

);

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Show a pop up with a statement

Here is one way

Names Default To Here( 1 );
dt = Current Data Table();
count = 0;
For( i = N Col( dt ), i >= 1, i--,
	If( (Col N Missing( Column( i ) ) / N Row()) == 1,
		dt << delete columns( i );
		count++;
	)
);

New Window( "Message", modal,
	H List Box(
		Spacer Box( size( 5, 0 ) ),
		Text Box( Char( count ) ),
		Text Box( " Columns Were Deleted" )
	)
);
Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: Show a pop up with a statement

Here is one way

Names Default To Here( 1 );
dt = Current Data Table();
count = 0;
For( i = N Col( dt ), i >= 1, i--,
	If( (Col N Missing( Column( i ) ) / N Row()) == 1,
		dt << delete columns( i );
		count++;
	)
);

New Window( "Message", modal,
	H List Box(
		Spacer Box( size( 5, 0 ) ),
		Text Box( Char( count ) ),
		Text Box( " Columns Were Deleted" )
	)
);
Jim
pmroz
Super User

Re: Show a pop up with a statement

Adding to Jim's approach, this code uses the caption command to show what columns are being deleted.  If the table is small the caption messages will flash by very quickly, but for larger tables it will give users an idea of progress.

Names Default To Here( 1 );
dt = Current Data Table();
count = 0;
nr = nrows(dt);
nc = ncols(dt);
For ( i = nc, i >= 1, i--,
	If ( Col N Missing( Column( i ) ) == nr,
		col_name = column(i) << get name;
		caption("Deleting column " || col_name);
		wait(0);
		dt << delete columns( i );
		count++;
	);
);
// Remove the caption box
caption(remove);
wait(0);
New Window( "Message", <<modal,
	Text Box( Char( count ) || " Columns were deleted" )
);