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
anders_bankefor
Level III

inputting data from an interactive interface

Hi,

In JSL would like to create an interactive interface were a user can input values into a column. The column should be of type Continuous.

For example, the user inputs a value into a dialog box which enters the value into a column:

x = UpperLimit, y = LowerLimit

Age   Name      UpperLimit      LowerLimit

40     Peter        30                   45

Does anyone have any suggestions of how to accomplish this?

- Anders

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: inputting data from an interactive interface

Anders,

If I am following what you want, the script below will input upper and lower limits and add them to a data table.  I have annotated the script to hopefully allow you to see what the example is doing.

Names Default To Here( 1 );

// Create the new data table and it"s columns
dt = New Table( "Limits" );
dt << New Column( "UpperLimit", Numeric, Continuous );
dt << New Column( "LowerLimit", Numeric, Continuous );

// Open a display window to enter the data into
InputWindow = New Window( "Enter Input",
// Add a verticle list box to structure the position of the display
V List Box(
  // Add some space
  Spacer Box( size( 1, 10 ) ),
  // Display the instruction text
  Text Box( " Enter in the inputs" ),
  Spacer Box( size( 1, 10 ) ),
  // The following displays need to be side by side
  H List Box(
   // Display text to infor the user what data to enter
   Text Box( "Enter in the Lower Limit" ),
   Spacer Box( size( 10, 1 ) ),
   // Use a number edit box to capture the users input and
   // give the display object the name "LLimit"
   LLimit = Number Edit Box( . ),
   Spacer Box( size( 10, 1 ) ),
   // Display text to infor the user what data to enter
   Text Box( "Enter in the Upper Limit" ),
   Spacer Box( size( 10, 1 ) ),
   // Use a number edit box to capture the users input and
   // give the display object the name "ULimit"
   ULimit = Number Edit Box( . )
  ),
  Spacer Box( size( 1, 10 ) ),
  // Add a couple of control buttons
  H List Box(
   // The first button box will add the values to the data table, if the
   // values are valid
   Button Box( "Add the Values",
   
    If( Is Missing( LLimit << get ) == 0 & Is Missing( ULimit << get ) == 0 & (ULimit << get) > (LLimit << get),
     // If the values are valid, add a row to the data table and set the values
     dt << add rows( 1 );
     dt:LowerLimit[N Rows( dt )] = LLimit << get;
     dt:UpperLimit[N Rows( dt )] = ULimit << get;
    ,
     // If the values are not valid, set them to missing and
     // display a dialog to the user
     LLimit << set( . );
     ULimit << set( . );
     Dialog( "The values entered are invalid:" );
    )
   ),
   Spacer Box( size( 10, 1 ) ),
   // This button box closes the display window
   Button Box( "Stop Adding", InputWindow << Close Window )
  )
)
);

Jim

View solution in original post

5 REPLIES 5
ian_jmp
Level X

Re: inputting data from an interactive interface

There are many ways to do this, and a good UI design depends on exactly what information you want to surface to the user so they can reliably perform the input task. Do you want or need to show all the rows in the table, or just one at a time? Do you need to also show the existing values in one or more of the other columns?

anders_bankefor
Level III

Re: inputting data from an interactive interface

Hi Ian and thank you for your quick answer.

well im new to JSL therefore I've not got a full grasp of the syntax yet and all my attempts of writing a code that will simply store an input from a user into a variable has therefore failed. However I do know some basics in java programming and the corresponding feature I'm looking for is a scanner class.

example in java:

Scanner sc = new Scanner (System.in);

Int Upperlimit = scanner.nextInt();

In JMP I would like it to work as following:

As far as I can imagine all te rows for both the new columns and other columns sould be visable (maybe this will change in the future).

try (

UpperLimit = scanner.nextInt

dt = Current Data Table ();

dt << New Column ("UpperLimit", Numeric, "Continuous", Values ( UpperLimit ) );

//the same should be done with LowerLimit

)

if (UpperLimit < LowerLimit, throw ("!Error") );

I hope you understood my examples.

BR

Anders

txnelson
Super User

Re: inputting data from an interactive interface

Anders,

If I am following what you want, the script below will input upper and lower limits and add them to a data table.  I have annotated the script to hopefully allow you to see what the example is doing.

Names Default To Here( 1 );

// Create the new data table and it"s columns
dt = New Table( "Limits" );
dt << New Column( "UpperLimit", Numeric, Continuous );
dt << New Column( "LowerLimit", Numeric, Continuous );

// Open a display window to enter the data into
InputWindow = New Window( "Enter Input",
// Add a verticle list box to structure the position of the display
V List Box(
  // Add some space
  Spacer Box( size( 1, 10 ) ),
  // Display the instruction text
  Text Box( " Enter in the inputs" ),
  Spacer Box( size( 1, 10 ) ),
  // The following displays need to be side by side
  H List Box(
   // Display text to infor the user what data to enter
   Text Box( "Enter in the Lower Limit" ),
   Spacer Box( size( 10, 1 ) ),
   // Use a number edit box to capture the users input and
   // give the display object the name "LLimit"
   LLimit = Number Edit Box( . ),
   Spacer Box( size( 10, 1 ) ),
   // Display text to infor the user what data to enter
   Text Box( "Enter in the Upper Limit" ),
   Spacer Box( size( 10, 1 ) ),
   // Use a number edit box to capture the users input and
   // give the display object the name "ULimit"
   ULimit = Number Edit Box( . )
  ),
  Spacer Box( size( 1, 10 ) ),
  // Add a couple of control buttons
  H List Box(
   // The first button box will add the values to the data table, if the
   // values are valid
   Button Box( "Add the Values",
   
    If( Is Missing( LLimit << get ) == 0 & Is Missing( ULimit << get ) == 0 & (ULimit << get) > (LLimit << get),
     // If the values are valid, add a row to the data table and set the values
     dt << add rows( 1 );
     dt:LowerLimit[N Rows( dt )] = LLimit << get;
     dt:UpperLimit[N Rows( dt )] = ULimit << get;
    ,
     // If the values are not valid, set them to missing and
     // display a dialog to the user
     LLimit << set( . );
     ULimit << set( . );
     Dialog( "The values entered are invalid:" );
    )
   ),
   Spacer Box( size( 10, 1 ) ),
   // This button box closes the display window
   Button Box( "Stop Adding", InputWindow << Close Window )
  )
)
);

Jim
anders_bankefor
Level III

Re: inputting data from an interactive interface

Thank you a lot, this was precisely what I was looking for and more!

Cheers

-Anders

ian_jmp
Level X

Re: inputting data from an interactive interface

If row-wise editing is OK, I wanted to also mention this:

Names Default To Here( 1 );

// Create the new data table and it"s columns

dt = New Table( "Limits" );

dt << New Column( "Lower Limit", Numeric, Continuous );

dt << New Column( "Upper Limit", Numeric, Continuous );

dt << rowEditor;

This has the shortcoming that it doesn't enforce the USL > LSL requirement, but this could possibly be done by subscribing to changes to 'dt' (look for 'Subscribe' in 'Help > Scripting Index'). Also, be aware that you can add column properties to the columns in the table http://www.jmp.com/support/help/Expression_Data.shtml, which include a 'range check' on the values.