How to use Radio BoxesI am brand new to JMP scripting and trying to self teach. I created a radio box:
New Window( "Example",
panelbox("Confidence Interval",
rb = Radio Box(
{"90%", "95%", "98%", "99%"},
Show( rb << Get() ),
),
My current question is how can I use the variable rb?
I tried this if(then) statement:
If(
:rb == "95%",
// then
:x = 1.96,
:rb == "90%", :x = 1.645,
:rb == "98%", :x = 2.326,
:rb == "99%", :x = 2.576,
)
but get this error message: "Name Unresolved: rb in access or evaluation of 'rb' , :rb/*###*/"
Here is the whole code.
Names Default To Here( 1 );
computeResults = Expr(
If(
:rb == "95%",
// then
:x = 1.96,
:rb == "90%", :x = 1.645,
:rb == "98%", :x = 2.326,
:rb == "99%", :x = 2.576,
)
);
New Window( "Example",
Panel Box( "Confidence Interval",
rb = Radio Box(
{"90%", "95%", "98%", "99%"},
Show( rb << Get() ),
),
),
H Center Box( Button Box( "Calculate Minimum Sample Size", computeResults ) ),
V List Box( Text Box( "" ), ciolb = Panel Box( "Result", x = Number Edit Box( "" ) ) )
);
Thanks for any help or suggestions. I'll be reading the scripting manual and check back later.
Re: How to use Radio BoxesYep, I see that. I just wanted to verify the theory. Thanks again.
Re: How to use Radio BoxesYou can do that. But in your case, since x is use in your display window, you need to understand that x will no longer point to the numbereditboxRe: How to use Radio BoxesI think I have an understanding of what is going on. Hopefully LAST question.
If I set a variable say x = 3 it looks like I can "reset" x later to say x = z+ y without an error (syntax error at least). Am I correct?
Re: How to use Radio BoxesSet and Get are exact opposites. If we look at
Match( self << Get Selected,
"95%", x << Set( 1.96 ); z = x << get;,
"90%", x << Set( 1.645 ); z = x << get;,
"98%", x << Set( 2.326 ); z = x << get;,
"99%", x << Set( 2.576 ); z = x << get;
)
The variable "X" is pointing to a display object. So to communicate with a display object, one passes messages to the object. Thus to assign a value to the object one passes the message to the object to "Set" the value. Thus,
x << Set( 1.96 );
The variable "Z" is just a memory variable( a scaler value). To assign a value to a scaler variable, one just uses an "=", such as
a = 42;
theParameterValue = b + c * 24;
but in your case, you want to set the scaler variable "Z" to the value from the Display Object, "X". So to do that, one uses the "=" to assign the value to variable "Z", but has to pass the message, "<< get" to the Display Object "X" to retrieve its current value.
z = x << get;
The statements could have also been written:
x << Set( 1.96 ); z = 1.96;
which might have been more understandable.
Re: How to use Radio BoxesThis feel very unintuitive. So Set and Get are simialr but different. Thanks again for the direction.
Re: How to use Radio BoxesThe issue you are having is that you are a little confused as what the "X" variable is. In the code that @vince_faller provided, "X" is associated with a DisplayBox object. More specifically, it is a NumberEditBox(), display object. The NumberEditBox() is an Object in your window. To set and get the values in the object, you use <<
z = x << get;
However, most scripts are structured to display a window to get and set information, but then close the window to do further calculations. Therefore, one typicaly moves the required values out of the display objects into standard JSL scalers, lists or matricies. For the NumberEditBox() I typically use a simple <
New Window( "Example",
Panel Box( "Confidence Interval",
rb = Radio Box(
{"90%", "95%", "98%", "99%"},
<<SET function=""></SET>
or you could actually just set the z value in the Radito Box()
New Window( "Example",
Panel Box( "Confidence Interval",
rb = Radio Box(
{"90%", "95%", "98%", "99%"},
<<SET function=""></SET>
Re: How to use Radio BoxesUmmmm ....
I used this code:
Match( rb << Get Selected,
"95%", x << Set( 1.96 ),
"90%", x << Set( 1.645 ),
"98%", x << Set( 2.326 ),
"99%", x << Set( 2.576 )
);
to display the z-score for a chosen CI via radio buttons. The x assigned and the correct z-score displayed.
I now want to use the z-score in a formula, but am getting this error:
Send Expects Scriptable Object in access or evaluation of 'Send' , z << /*###*/Set( 1.96 ) /*###*/
Is the x-value as obtained in the above code not a numeric value I can use in a formula? Is there a way to "force" it to be/act numeric?
Re: How to use Radio BoxesThanks for the heads up, definitely going to look that over closely.
Re: How to use Radio BoxesYou mention that you are self teaching JSL. Given that, I suggest you take the time to read the Scripting Guide
Help==>Books==>Scripting Guide
and that you become very familiar with the Scripting Index. In the index, you will find all of the messages, etc. that can be sent to the functions and objects, and will give you examples of each. Below is the example that is referenced in the section of the guide for Radio Button(), using a Set Function() for processing

Re: How to use Radio BoxesThank you very much for the reply. I will definitely study up more on match and that "Set Function" you suggested. Thank you again!
Re: How to use Radio BoxesYou're scoping the variables as columns when you do :rb. You have to send the graphic objects << messages.
Names Default To Here( 1 );
computeResults = Expr(
match(rb << Get Selected,
"95%", x << Set(1.96),
"90%", x << Set(1.645),
"98%", x << Set(2.326),
"99%", x << Set(2.576)
);
);
New Window( "Example",
Panel Box( "Confidence Interval",
rb = Radio Box(
{"90%", "95%", "98%", "99%"},
Show( rb << Get() ),
),
),
H Center Box( Button Box( "Calculate Minimum Sample Size", computeResults ) ),
V List Box( Text Box( "" ), ciolb = Panel Box( "Result", x = Number Edit Box( "" ) ) )
);
//Or you could make the radiobox actually just change it
New Window( "Example",
Panel Box( "Confidence Interval",
rb = Radio Box(
{"90%", "95%", "98%", "99%"},
<<SET function=""></SET>Re: How to use Radio Boxesedit: I'm sorry, the goal is to recognize which radio box is marked and then print out the z-score.