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

Set user in put as new variable

Hello, 

 

I am looking to create a script which takes a user input and outputs these inputs into a data table. 

My script below outputs a data table but does not insert the user variables, would someone be able to help as I think I may be misunderstanding how to insert it. 

 

v1 = text = " ID"; // two numbers with default

w = New Window( "Synch Request", // opens a window with a title and this content...
    Border Box( top( 20 ), bottom( 20 ), Left( 20 ), Right( 20 ), // window dressing 
        V List Box( // V and H lists nest to organize the display boxes
            H Center Box( Text Box( "Please select the tool you wish to view and the date to view from" ) ), // a second title, centered
            Spacer Box( size( 1, 30 ) ), // a little vertical space
            H List Box( Text Box( "Tool: " ), tool = Text Edit Box( v1 ) ), // data entry
            Spacer Box( size( 1, 10 ) ), // a little vertical space
            H List Box( Text Box( "Date: " ), date = Calendar Box(  ) ), // more data entry
            Spacer Box( size( 1, 30 ) ), // a little vertical space
            H Center Box( // center the button
                Button Box( "Execute", // this script runs when the button is pressed...

                    // make a new table with the values...
                    tool_val = tool << GetSelected();
					date_val = date << GetSelected();
					dt = New Table( "Untitled", 
					New Column( "a", Character, Set Values( tool_val ) ),
					New Column( "b", Numeric,
						"Continuous",
						//Required due to original format
						Format("y/m/d h:m:s"), Set Values( {date} ) ) );
                    
                    
                    // optionally, close the dialog. Or, you might want to run it again...
                    w << closeWindow; // just the dialog, not the report
                )
            )
        )
    )
);
~ Luke :)
4 REPLIES 4
jthi
Super User

Re: Set user in put as new variable

Check out log, it gives quite good error message.

 

Here is possibly fixed script with some supporting prints (I get values with something else than << get selected, also I set values in different way to the new table).

 

Names Default To Here(1);

v1 = text = " ID"; // two numbers with default

w = New Window("Synch Request", // opens a window with a title and this content...
	Border Box(top(20), bottom(20), Left(20), Right(20), // window dressing 
		V List Box( // V and H lists nest to organize the display boxes
			H Center Box(Text Box("Please select the tool you wish to view and the date to view from")), // a second title, centered
			Spacer Box(size(1, 30)), // a little vertical space
			H List Box(Text Box("Tool: "), tool = Text Edit Box(v1)), // data entry
			Spacer Box(size(1, 10)), // a little vertical space
			H List Box(Text Box("Date: "), date = Calendar Box()), // more data entry
			Spacer Box(size(1, 30)), // a little vertical space
			H Center Box( // center the button
				Button Box("Execute", // this script runs when the button is pressed...

					// make a new table with the values...
					tool_val = tool << get text;
					show(tool_val);
					date_val = date << get date;
					show(date_val);
					dt = New Table("Untitled",
						New Column("a", Character, Values(Eval List({tool_val}))),
						New Column("b",
							Numeric,
							"Continuous", 
						//Required due to original format
							Format("y/m/d h:m:s"),
							Values(Eval List({date_val}))
						)
					);
                    // optionally, close the dialog. Or, you might want to run it again...
					w << closeWindow; // just the dialog, not the report
				)
			)
		)
	)
);

Depending on your script, it might also be a good idea to consider using modal window

 

-Jarmo
LukeFarrell
Level III

Re: Set user in put as new variable

Thank you, the main idea of the script is to input these two variables into a separate script. 

I have the first variable of ID working, however the date does not seem to be working. 

~ Luke :)
txnelson
Super User

Re: Set user in put as new variable

It works for me on Windows 10, with JMP 15 and JMP 16.  What version of JMP, and what operating system?

Jim
jthi
Super User

Re: Set user in put as new variable

Check out the log, what does

					show(date_val);

print?

 

With the date issue could also be with this format:

 

Format("y/m/d h:m:s"),

JMP can be a bit finnicky with formats from time to time. You could remove the formatting from the "b" column and see if it fills the row with datenum value. Then you can try to see which formats you have available from format menu.

jthi_0-1647677700701.png

jthi_1-1647677712418.png

 

 

 

-Jarmo