The 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 <<Set and <<Get messages. And, as long as the display window remains open, you can get and set the values in that object.
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 <<Set Function message. It executes each time the value in the NumberEditBox() changes.
New Window( "Example",
Panel Box( "Confidence Interval",
rb = Radio Box(
{"90%", "95%", "98%", "99%"},
<<Set Function(
Function( {self},
Match( self << Get Selected,
"95%", x << Set( 1.96 ),
"90%", x << Set( 1.645 ),
"98%", x << Set( 2.326 ),
"99%", x << Set( 2.576 )
)
)
),
),
),
H Center Box(
Button Box( "Calculate Minimum Sample Size", computeResults )
),
V List Box(
tb = Text Box( "" ),
ciolb = Panel Box( "Result",
x = Number Edit Box(
1.645,
7,
<<set function( Function( {this}, z = this << get ) )
)
)
)
);
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(
Function( {self},
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;
)
)
),
),
)
H Center Box(
Button Box( "Calculate Minimum Sample Size", computeResults )
),
V List Box(
tb = Text Box( "" ),
ciolb = Panel Box( "Result",
x = Number Edit Box(
1.645
)
)
)
);
Jim