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
Ceg1
Level II

Deleting column/table variable that is referenced in formula using JSL

Hi,

As stated in the topic of this post, I observed that JSL commands "Delete Column" or "Delete Table Variable" don't work when either column has a function or table variable is a part of a function.

When performing this action "by hand" there is an extra warning window, that informs user about consequences of such action and allows to choose an action. 

I understand that this behaviour was introduced intentionally, and I am totally fine with that.

 

I would like to ask if there is any option/argument/flag/command to bypass this window when deleting column/table variable using JSL?

 

Thank you for help.

2 REPLIES 2
txnelson
Super User

Re: Deleting column/table variable that is referenced in formula using JSL

I am not able to replicate what I understand as the issue you are asking about. The below scripts are deleting a table variable and a column from within a formula and a function within each formula.

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

dt << New Table Variable( "Days", 42 );
Wait( 5 );
dt << New Column( "test",
	formula(
		delTVar = Function( {theVar},
			dt << Delete Table Variable( theVar )
		);
		rc = delTVar( "Days" );
		:weight;
	)
);
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/big class.jmp" );

Wait( 5 );
dt << New Column( "test",
	formula(
		delCol = Function( {theCol},
			dt << delete columns( theCol )
		);
		rc = delCol( "height" );
		:weight;
	)
);
Jim
jthi
Super User

Re: Deleting column/table variable that is referenced in formula using JSL

I think there isn't any flag that can do this. Maybe a place for wish list item, I think the flag should be similarly configurable as the interactive version which asks to remove refs, formula or cancel (I would maybe add Throw also).

 

 

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

dt << New Column("f", Numeric, Continuous, Formula(:height*weight));
dt << Delete Columns({"height", "weight"});

Will print to log:

 

Cannot delete the selected columns while some are referenced by the formulas of remaining columns.
Removing a formula leaves the data unchanged. Removing references replaces each reference with an empty value. These effects are permanent and cannot be undone.

Scriptable[]

 

You could capture this message with Log Capture() and then perform some JSL tricks to remove references / formulas beforehand.

-Jarmo