Choose Language Hide Translation Bar
Highlighted
Mosharo
Level I

creating and filling a new column with data defined by user

Hi,

 

I'm an inexperienced user of JMP scripting need helps on how to add a new column, and the data of new column will define by the user with a fixed number. Meaning that, whenever I run the code, it should ask the interested number of filling up into a new column. Actually, I have a different number and different task (for new column) needs for filling up into the same data table.

 

 

2 REPLIES 2
Highlighted
ih
ih
Level VII

Re: creating and filling a new column with data defined by user

If I understand your request, it sounds like you want to both as the user for a value and then use that value in a formula.  This might help get you started:

 

//Make sure variables names defined here do not interfere with other scripts
Names default to here(1);

//start by opening a data table.  Instead of this, you could just use
// dt = current data table();
dt = Open("$Sample_Data/iris.jmp");

dt << New Script(
	"New Column",
	//Open a new window which...
	win = New Window ( "Create a column",
		Show Menu( 0 ),
		Show Toolbars( 0 ),
		v list box(
			Text Box( "Add a new column."),
			Spacer box( Size( 20,20 ) ),
			
			//asks the user for a column name...
			Text Box("Enter a column name"),
			tebName =  Text Edit Box( "Column 1", Set Width( 200 ) ),
			Spacer box( Size( 10,10 ) ),
			
			
			//and a value...
			Text Box("Enter a value in the column"),
			nebValue = Number Edit Box( 0 ),
			Spacer box( Size( 10,10 ) ),

			H list box(
				//and includeds a button with a script that creates the column...
				Button Box( "Create A Column",
				
					//Use Eval, Eval Expr, and Expr to put the RESULT of the expression "nebValue << Get" into the formula
					//instead of the expression itself
					Names default to here( 1 );
					dt = current data table();
					Eval( Eval Expr(
						dt << New Column( tebName << Get Text, Numeric, "Continuous", Format("Best", 12), Formula( Expr( nebValue << Get ) ) )
					) )
				),

				//and another button to close the window.
				Button Box( "Close",
					win << Close Window
				)
			)
		)
	);
);
Highlighted
Mosharo
Level I

Re: creating and filling a new column with data defined by user

Hi,

 

Appreciate for your help and it mostly assists me to complete my scripts. Actually, my tasks and mission is about the need to pull out the csv file that didn't include a complete data and make it complete with a variable data depends on my project. Seems your code helps me more, so now I need to think about how to combine from the initial stage until I get the graph just only using single code. Perhaps it can be done and also need some expert in this community group to advise. Thank you very much.

 

Article Labels