Subscribe Bookmark RSS Feed

Get values from Modal New Window

katief

Staff

Joined:

Oct 21, 2011

I am having trouble getting values after I use a modal New Window Box.

If I run the example from the JMP 9 Scripting Guide:

New Window("Set a Value",<<Modal,

     TextBox("Set this Value"),

     variablebox = Number Edit Box(42),

     Button Box("OK"),

     Button Box("Cancel")

);

variablebox<<get;

I get this error: "Send Expects Scriptable Object in access or evaluation of 'Send', variablebox<<get

On the other hand:

When I run just the code

variablebox = Number Edit Box(42);

variablebox<<get;

I get:

42

Anyone know what I've done wrong here? I can't seem to make  "get" retrieve variables from any of the modal windows I've tried.

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

As soon Ok or Cancel is clicked, the reference is forgotten, and hence the error. Put the get command, or any script, inside the Ok-button to ensure that it will run before the modal window is history.

New Window( "Set a Value",

          <<Modal,

  Text Box( "Set this Value" ),

          variablebox = Number Edit Box( 42 ),

          Button Box( "OK", value = variablebox << get ),

  Button Box( "Cancel" )

);

Show( value );


4 REPLIES
katief

Staff

Joined:

Oct 21, 2011

I just noticed something interesting:

If I run the New Window as a block of code by itself and then run the variablebox<<get by itself, I get the scriptable object error. If I run the New Window code with the variablebox<<get command all at once, I get the correct value returned.

Solution

As soon Ok or Cancel is clicked, the reference is forgotten, and hence the error. Put the get command, or any script, inside the Ok-button to ensure that it will run before the modal window is history.

New Window( "Set a Value",

          <<Modal,

  Text Box( "Set this Value" ),

          variablebox = Number Edit Box( 42 ),

          Button Box( "OK", value = variablebox << get ),

  Button Box( "Cancel" )

);

Show( value );


katief

Staff

Joined:

Oct 21, 2011

Thank you for the help!

David_Burnham

Super User

Joined:

Jul 13, 2011

Just to be slightly pedantic about this - the reference is only lost once the script completes execution.  So the example you gave does work correctly, but only if you allow the entire script to execute (as opposed to running a partial block of code).  Therefore if you were to create a modal window without explicit button display boxes, it would still work e.g.

New Window("Set a Value",<<Modal,

     TextBox("Set this Value"),

     variablebox = Number Edit Box(42),

);

x = variablebox<<get;

show(x);

-Dave

-Dave