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
haider15
Level I

Script window for adding three new columns, two columns with constant fixed values, and one column with numbers

Dear all 

 

I would like to create a script to add three new columns in my data table. Two columns will have fixed constant values and one will have numbers. Ideally script should open up a pop up window and ask for the constant values. Thankyou for helping me with this 

1st column heading: Process (Script should open a pop up window asking for the constant value in the process column)

2nd column heading: Lotslot (Script should open a pop up window asking for the constant value in the process column)

3rd column heading: Dose (this column with have fixed set of numbers starting from a fixed number on first row (to be input by me by a popup) and then decreasing through the column by a value of 2 till the end of column)

1 REPLY 1
txnelson
Super User

Re: Script window for adding three new columns, two columns with constant fixed values, and one column with numbers

Here is an example, taking the script example from the Scripting Index for New Window.  For the most part, it was just replicated 3 times with your specification changed for each entry

names default to here(1);
dt=current data table();
ex = New Window( "Process",
	<<Type( "Modal Dialog" ),
	<<Return Result,
	V List Box(
		Text Box( "Enter the constant for the Process column" ),
		H List Box( myEditBox = Number Edit Box(  ) ),
		H List Box( Button Box( "OK" ), Button Box( "Cancel" ) )
	)
);

//  the Modal window must be closed before the following code runs

If(
	ex["button"] == 1 // not canceled
, dt << New Column("Process", set each value(ex["myEditBox"])),
	Write( "CANCEL" ); // cancel button or red X was pressed
);


ex = New Window( "LotSlot",
	<<Type( "Modal Dialog" ),
	<<Return Result,
	V List Box(
		Text Box( "Enter the constant for the Lotslot column" ),
		H List Box( myEditBox = Number Edit Box( ) ),
		H List Box( Button Box( "OK" ), Button Box( "Cancel" ) )
	)
);

//  the Modal window must be closed before the following code runs

If(
	ex["button"] == 1 // not canceled
, dt << New Column("LotSlot", set each value(ex["myEditBox"])),
	Write( "CANCEL" ); // cancel button or red X was pressed
);


ex = New Window( "Dose",
	<<Type( "Modal Dialog" ),
	<<Return Result,
	V List Box(
		Text Box( "Enter the starting number for the Dose column" ),
		H List Box( myEditBox = Number Edit Box( ) ),
		H List Box( Button Box( "OK" ), Button Box( "Cancel" ) )
	)
);

//  the Modal window must be closed before the following code runs

If(
	ex["button"] == 1 // not canceled
, dt << New Column("Dose", set each value(ex["myEditBox"]-(Row()-1)*2)),
	Write( "CANCEL" ); // cancel button or red X was pressed
);
Jim