More help with ModalHi,
l am trying to incorporate some display boxes in some code, i was hoping that entering a variable name, from a data table, into the display box would populate into the shaded areas in the Syntax below, l have tried using (var_name["nameVar"] into the highlighted areas to no avail, does anyone have any ideas???
Names Default To Here( 1 );
Clear Symbols();
pb = Page Break Box();
fileopen = "\\Kate\TIV\JMP Data.jmp";
var_name = New Window( "Variable Analysis",
<<MODAL></MODAL>
Thanks to all replies
Re: More help with ModalHi,
The code i pasted this morning needs to be amended for the histogram from Variables (Column ( As Column ( namevar ))), to Variables ( X ( As Column ( namevar))), to get the histogram working again. The below code is the code that worked when all the reference lines on the histogram were right in place, not sure why changing the code slightly upset the histogram.
Names Default To Here ( 1 );
Clear Symbols ();
pb = Page Break Box();
fileopen= "\\cslg1.cslg.net\home\U0053680\home\desktop\Kate\TIV\JMP Data.jmp";
var_name = New Window ("Variable Analysis", << Modal, << Return Result,
Text Box ("Please enter Variable to analyse"),//Create the display box
HListBox(
LineupBox (NCol (2),
Text Box ("Enter Variable Name"), nameVar = textEditBox("QA5030 Thiomersal FBV TIV (%w/v)"),
), // end of lineupbox
LineupBox ( NCol (1), ButtonBox ("OK"), ButtonBox ("Cancel"))
) // end HlistBox
);
show (var_name, var_name ["nameVar"] );
If (var_name ["Button"] == -1,
Caption (" Wait...Aborting..."); Wait (3) ; Caption(Remove); Throw());
StatusMsg ("Processing next steps");
RemoveFrom (var_name, NItems(var_name)); // Removes the last item "Button 1" from the assignment list
Eval List(var_name); // the assignment from the display box are run
Show ( var_name, nameVar );
hist_param = New Window ("Histogram Bin Parameters", << Modal, << Return Result,
Text Box ("Select Histogram Bin Parameters"),//Create the display box
HListBox(
LineupBox (NCol (2),
Text Box ("Minimum Amount"), miniAmount = numberEditBox(0.0078),
Text Box ("Maximum Amount"), maxAmount = numberEditBox(0.0122),
Text Box ("Bins Increase by"), increaseAmount = numberEditBox(0.0002),
), // end of lineupbox
LineupBox ( NCol (1), ButtonBox ("OK"), ButtonBox ("Cancel"))
) // end HlistBox
);
show (hist_param, hist_param ["miniAmount"], hist_param ["maxAmount"], hist_param ["increaseAmount"],
hist_param ["Button"] );
If (hist_param ["Button"] == -1,
Caption (" Wait...Aborting..."); Wait (3) ; Caption(Remove); Throw());
StatusMsg ("Processing next steps");
RemoveFrom (hist_param, NItems(hist_param)); // Removes the last item "Button 1" from the assignment list
Eval List(hist_param); // the assignment from the display box are run
Show ( hist_param, miniAmount, maxAmount, increaseAmount );
ref_lines = New Window ("Reference Lines on Histogram", << Modal, << Return Result,
Text Box ("Select where to place Histogram Reference Lines"),//Create the display box
HListBox(
LineupBox (NCol (2),
Text Box ("LSL"), lowerLimit = numberEditBox(0.008),
Text Box ("USL"), UpperLimit = numberEditBox(0.0120),
Text Box ("-3 Standard Deviations"), lesstandDev = numberEditBox(0.008459),
Text Box ("+3 Standard Devaitions"), maxstandDev = numberEditBox(0.010926),
Text Box ("Mean"), meanAmount = numberEditBox(0.0097375),
), // end of lineupbox
LineupBox ( NCol (1), ButtonBox ("OK"), ButtonBox ("Cancel"))
) // end HlistBox
);
show (ref_lines, ref_lines ["lowerLimit"], ref_lines["UpperLimit"], ref_lines ["lesstandDev"], ref_lines ["maxstandDev"], ref_lines ["meanAmount"],
ref_lines ["Button"] );
If (ref_lines ["Button"] == -1,
Caption (" Wait...Aborting..."); Wait (3) ; Caption(Remove); Throw());
StatusMsg ("Processing next steps");
RemoveFrom (ref_lines, NItems(ref_lines)); // Removes the last item "Button 1" from the assignment list
Eval List(ref_lines); // the assignment from the display box are run
Show ( ref_lines, lowerLimit, UpperLimit, lesstandDev, maxstandDev, meanAmount);
Eval(
Substitute(
Expr(
distrib = New Window( namevar,
Distribution(
Continuous Distribution(
Column( As Column( namevar ) ),
Normal Quantile Plot( 1 ),
Fit Distribution( Normal( Goodness of Fit( 1 ) ) )
),
SendToReport( Dispatch( {__myvar__}, "", Picture Box( 5 ), {Set Summary Behavior( "Collapse" )} ) )
)
) << Move Window( 634, 43 ) << Size Window( 807, 861 ) << Set Window Icon( "Distrib" )
),
Expr( __myvar__ ), namevar
)
);
Graph Builder(
Variables( X( :Name( "QA5030 Thiomersal FBV TIV (%w/v)" ) ) ),
Elements( Histogram( X, Legend( 2 ) ), Histogram( X, Legend( 3 ) ) ),
Local Data Filter,
SendToReport(
Dispatch( {}, "Histogram", OutlineBox, {Close( 1 )} ),
Dispatch( {}, "Histogram", Outline Box( 2 ), {Close( 1 )} ),
Dispatch(
{},
"QA5030 Thiomersal FBV TIV (%w",
ScaleBox,
{Min( hist_param ["miniAmount"] ), Max(hist_param ["maxAmount"] ), Inc(hist_param ["increaseAmount"] ), Minor Ticks( 0 ),
Add Ref Line( ref_lines ["lowerLimit"], "Solid", "Blue", "LSL", 1 ),
Add Ref Line( ref_lines["UpperLimit"], "Solid", "Blue", "USL", 1 ),
Add Ref Line( ref_lines ["lesstandDev"], "Solid", "Red", "-3SP", 1 ),
Add Ref Line(ref_lines ["maxstandDev"], "Solid", "Red", "+3SP", 1 ),
Add Ref Line( ref_lines ["meanAmount"], "Solid", "Green", "Mean", 1 )}
)
)
);
Control Chart Builder(
Size( 1187, 500 ),
Show Capability( 0 ),
Variables(
Subgroup( :Lot Number ),
Y( :Name( "QA5030 Thiomersal FBV TIV (%w/v)" ) )
),
Chart( Position( 1 ), Limits( Sigma( Moving Range ) ) ),
Chart( Position( 2 ), Limits( Sigma( Moving Range ) ) ),
SendToReport(
Dispatch(
{},
"QA5030 Thiomersal FBV TIV (%w",
ScaleBox,
{Min( 0.00779755917159763 ), Max( 0.0125370562130178 ), Inc( 0.0005 ),
Minor Ticks( 0 ), Add Ref Line(
0.012,
"Solid",
"Blue",
"USL (0.012)",
1
), Add Ref Line( 0.008, "Solid", "Blue", "LSL (0.008)", 1 )}
)
)
);Re: More help with ModalHi txnelson,
l have attached the data table, it's still a work in progress but its great experience for me working with JMP for the first time and getting to know the syntax, so what l need to do is have the ability to switch between variables, in this case QA5030 and the log 10 of the same and have the same reports products, not sure if am going about it the right way. at the end i need to suppress all the individual logs and produce a complete log of the distribution, histogram and control charts and be able to produce a PDF. Below is the code so far:
Names Default To Here ( 1 );
Clear Symbols ();
pb = Page Break Box();
fileopen= "\\cslg1.cslg.net\home\U0053680\home\desktop\Kate\TIV\JMP Data.jmp";
var_name = New Window ("Variable Analysis", << Modal, << Return Result,
Text Box ("Please enter Variable to analyse"),//Create the display box
HListBox(
LineupBox (NCol (2),
Text Box ("Enter Variable Name"), nameVar = textEditBox("QA5030 Thiomersal FBV TIV (%w/v)"),
), // end of lineupbox
LineupBox ( NCol (1), ButtonBox ("OK"), ButtonBox ("Cancel"))
) // end HlistBox
);
show (var_name, var_name ["nameVar"] );
If (var_name ["Button"] == -1,
Caption (" Wait...Aborting..."); Wait (3) ; Caption(Remove); Throw());
StatusMsg ("Processing next steps");
RemoveFrom (var_name, NItems(var_name)); // Removes the last item "Button 1" from the assignment list
Eval List(var_name); // the assignment from the display box are run
Show ( var_name, nameVar );
hist_param = New Window ("Histogram Bin Parameters", << Modal, << Return Result,
Text Box ("Select Histogram Bin Parameters"),//Create the display box
HListBox(
LineupBox (NCol (2),
Text Box ("Minimum Amount"), miniAmount = numberEditBox(0.00728),
Text Box ("Maximum Amount"), maxAmount = numberEditBox(0.0122),
Text Box ("Bins Increase by"), increaseAmount = numberEditBox(0.0002),
), // end of lineupbox
LineupBox ( NCol (1), ButtonBox ("OK"), ButtonBox ("Cancel"))
) // end HlistBox
);
show (hist_param, hist_param ["miniAmount"], hist_param ["maxAmount"], hist_param ["increaseAmount"],
hist_param ["Button"] );
If (hist_param ["Button"] == -1,
Caption (" Wait...Aborting..."); Wait (3) ; Caption(Remove); Throw());
StatusMsg ("Processing next steps");
RemoveFrom (hist_param, NItems(hist_param)); // Removes the last item "Button 1" from the assignment list
Eval List(hist_param); // the assignment from the display box are run
Show ( hist_param, miniAmount, maxAmount, increaseAmount );
ref_lines = New Window ("Reference Lines on Histogram", << Modal, << Return Result,
Text Box ("Select where to place Histogram Reference Lines"),//Create the display box
HListBox(
LineupBox (NCol (2),
Text Box ("LSL"), lowerLimit = numberEditBox(0.008),
Text Box ("USL"), UpperLimit = numberEditBox(0.0120),
Text Box ("-3 Standard Deviations"), lesstandDev = numberEditBox(0.008459),
Text Box ("+3 Standard Devaitions"), maxstandDev = numberEditBox(0.010926),
Text Box ("Mean"), meanAmount = numberEditBox(0.009375),
), // end of lineupbox
LineupBox ( NCol (1), ButtonBox ("OK"), ButtonBox ("Cancel"))
) // end HlistBox
);
show (ref_lines, ref_lines ["lowerLimit"], ref_lines["UpperLimit"], ref_lines ["lesstandDev"], ref_lines ["maxstandDev"], ref_lines ["meanAmount"],
ref_lines ["Button"] );
If (ref_lines ["Button"] == -1,
Caption (" Wait...Aborting..."); Wait (3) ; Caption(Remove); Throw());
StatusMsg ("Processing next steps");
RemoveFrom (ref_lines, NItems(ref_lines)); // Removes the last item "Button 1" from the assignment list
Eval List(ref_lines); // the assignment from the display box are run
Show ( ref_lines, lowerLimit, UpperLimit, lesstandDev, maxstandDev, meanAmount);
Eval(
Substitute(
Expr(
distrib = New Window( namevar,
Distribution(
Continuous Distribution(
Column( As Column( namevar ) ),
Normal Quantile Plot( 1 ),
Fit Distribution( Normal( Goodness of Fit( 1 ) ) )
),
SendToReport( Dispatch( {__myvar__}, "", Picture Box( 5 ), {Set Summary Behavior( "Collapse" )} ) )
)
) << Move Window( 634, 43 ) << Size Window( 807, 861 ) << Set Window Icon( "Distrib" )
),
Expr( __myvar__ ), namevar
)
);
Eval(
Substitute(
Expr(
Graph Builder(
Variables( Column( As Column( namevar ) ) ),
Elements( Histogram( X, Legend( 2 ) ), Histogram( X, Legend( 3 ) ) ),
Local Data Filter,
SendToReport(
Dispatch( {}, "Histogram", OutlineBox, {Close( 1 )} ),
Dispatch( {}, "Histogram", Outline Box( 2 ), {Close( 1 )} ),
Dispatch(
{__myvar__},
" ",
ScaleBox,
{Min( hist_param["miniAmount"] ), Max( hist_param["maxAmount"] ), Inc( hist_param["increaseAmount"] ), Minor Ticks( 0 ),
Add Ref Line( ref_lines["lowerLimit"], "Solid", "Blue", "LSL", 1 ), Add Ref Line(
ref_lines["UpperLimit"],
"Solid",
"Blue",
"USL",
1
), Add Ref Line( ref_lines["lesstandDev"], "Solid", "Red", "-3SP", 1 ), Add Ref Line(
ref_lines["maxstandDev"],
"Solid",
"Red",
"+3SP",
1
), Add Ref Line( ref_lines["meanAmount"], "Solid", "Green", "Mean", 1 )}
)
)
)
),
Expr( __myvar__ ), namevar
)
);
Eval(
Substitute(
Expr(
Control Chart Builder(
Size( 1187, 500 ),
Show Capability( 0 ),
Variables( Subgroup( :Lot Number ), Y( As Column( namevar ) ) ),
Chart( Position( 1 ), Limits( Sigma( Moving Range ) ) ),
Chart( Position( 2 ), Limits( Sigma( Moving Range ) ) ),
SendToReport(
Dispatch(
{},
__myvar__,
ScaleBox,
{Min( 0.00779755917159763 ), Max( 0.0125370562130178 ), Inc( 0.0005 ), Minor Ticks( 0 ),
Add Ref Line( 0.012, "Solid", "Blue", "USL (0.012)", 1 ), Add Ref Line( 0.008, "Solid", "Blue", "LSL (0.008)", 1 )}
)
)
)
),
Expr( __myvar__ ), namevar
)
);Re: More help with ModalI don't think I can do more unless you provide me with a sample of your data table.
Re: More help with ModalHi Txnelson,
and thanks once again, the code has had a little stumble when i am trying to run it , it doesnt complete building the histogram, any ideas??
Thanks for the tip on the right click and "Reformat Script" might help with my formatting as well.
I'm hoping the references will work, once its all finished will show you and get some advice.
Thanks again
Re: More help with Modal1. There were too many ")". You did not properly paste in the code for both the Graph Builder and the Control Chart Builder. You can easily select the subsections of code, such as taking everything from the "Eval" in front of the Graph Builder, and select all of the code through the ");" at the end of the Eval section, and then right click on the selected code, and select "Reformat Script. It will parse the code, and give you any errors that it finds. That would have quickly told you that you do not have matching "()";
2. The code to run the platforms was incorrect. I had to change a few different pieces of syntax to make the code correct. As an illustration, you had specified in the Control Chart Builder
Variables( Subgroup( :Lot Number ), Y( column( As Column( namevar ) ) ) ),
The "Y( column( As Column( namevar .........." is correct syntax for the Distribution Platform, but not for the Control Chart Builder Platform. There is no "Column()" function. So the code needed to be changed to:
Variables( Subgroup( :Lot Number ), Y( As Column( namevar ) ) )
3. You have several references to items like hist_param["miniAmount"] and "ref_lines["lesstandDev"]" that I can not determine if they will parse correctly, since I don't have the code in front of the Eval() sections. So I guess you are on your own for that.
Here is a copy of the modified code. Make sure you read the documentation on the Substitute() function, so you understand how it is working,
Eval(
Substitute(
Expr(
Graph Builder(
Variables( Column( As Column( namevar ) ) ),
Elements( Histogram( X, Legend( 2 ) ), Histogram( X, Legend( 3 ) ) ),
Local Data Filter,
SendToReport(
Dispatch( {}, "Histogram", OutlineBox, {Close( 1 )} ),
Dispatch( {}, "Histogram", Outline Box( 2 ), {Close( 1 )} ),
Dispatch(
{__myvar__},
" ",
ScaleBox,
{Min( hist_param["miniAmount"] ), Max( hist_param["maxAmount"] ), Inc( hist_param["increaseAmount"] ), Minor Ticks( 0 ),
Add Ref Line( ref_lines["lowerLimit"], "Solid", "Blue", "LSL", 1 ), Add Ref Line(
ref_lines["UpperLimit"],
"Solid",
"Blue",
"USL",
1
), Add Ref Line( ref_lines["lesstandDev"], "Solid", "Red", "-3SP", 1 ), Add Ref Line(
ref_lines["maxstandDev"],
"Solid",
"Red",
"+3SP",
1
), Add Ref Line( ref_lines["meanAmount"], "Solid", "Green", "Mean", 1 )}
)
)
)
),
Expr( __myvar__ ), namevar
)
);
Eval(
Substitute(
Expr(
Control Chart Builder(
Size( 1187, 500 ),
Show Capability( 0 ),
Variables( Subgroup( :Lot Number ), Y( As Column( namevar ) ) ),
Chart( Position( 1 ), Limits( Sigma( Moving Range ) ) ),
Chart( Position( 2 ), Limits( Sigma( Moving Range ) ) ),
SendToReport(
Dispatch(
{},
__myvar__,
ScaleBox,
{Min( 0.00779755917159763 ), Max( 0.0125370562130178 ), Inc( 0.0005 ), Minor Ticks( 0 ),
Add Ref Line( 0.012, "Solid", "Blue", "USL (0.012)", 1 ), Add Ref Line( 0.008, "Solid", "Blue", "LSL (0.008)", 1 )}
)
)
)
),
Expr( __myvar__ ), namevar
)
);Re: More help with ModalHi txnelson,
This worked a treat, one more question, using your reply as a template shouldn't the following work as well??
Eval (
Substitute (
Expr (
Graph Builder(
Variables( Column ( As Column (namevar) ) ) ),
Elements( Histogram( X, Legend( 2 ) ), Histogram( X, Legend( 3 ) ) ),
Local Data Filter,
SendToReport(
Dispatch( {}, "Histogram", OutlineBox, {Close( 1 )} ),
Dispatch( {}, "Histogram", Outline Box( 2 ), {Close( 1 )} ),
Dispatch( { __myvar__ }, " ",
ScaleBox,
{Min( hist_param ["miniAmount"] ), Max(hist_param ["maxAmount"] ), Inc(hist_param ["increaseAmount"] ), Minor Ticks( 0 ),
Add Ref Line( ref_lines ["lowerLimit"], "Solid", "Blue", "LSL", 1 ),
Add Ref Line( ref_lines["UpperLimit"], "Solid", "Blue", "USL", 1 ),
Add Ref Line( ref_lines ["lesstandDev"], "Solid", "Red", "-3SP", 1 ),
Add Ref Line(ref_lines ["maxstandDev"], "Solid", "Red", "+3SP", 1 ),
Add Ref Line( ref_lines ["meanAmount"], "Solid", "Green", "Mean", 1 )}
Expr ( __myvar__ ), namevar
) ) )
)
)
);
Eval (
Substitute (
Expr (
Control Chart Builder(
Size( 1187, 500 ),
Show Capability( 0 ),
Variables(
Subgroup( :Lot Number ),
Y( Column ( As Column (namevar) ) )
),
Chart( Position( 1 ), Limits( Sigma( Moving Range ) ) ),
Chart( Position( 2 ), Limits( Sigma( Moving Range ) ) ),
SendToReport(
Dispatch( { __myvar__ }, " ",
ScaleBox,
{Min( 0.00779755917159763 ), Max( 0.0125370562130178 ), Inc( 0.0005 ),
Minor Ticks( 0 ), Add Ref Line(
0.012,
"Solid",
"Blue",
"USL (0.012)",
1
), Add Ref Line( 0.008, "Solid", "Blue", "LSL (0.008)", 1 )}
Expr ( __myvar__ ), namevar
) ) ) )
)
);Its for a Histogram and a control chart, but i cant seem to get it working.
Thanks heaps
Re: More help with ModalThanks pmroz, you are not wrong, my formatting is awful and something i need to work on, i didnt use the button because i wanted to highlight some thing in the code and using the button wouldn't let me highlight!!!!
Re: More help with ModalThe main issue you are having is that a couple of places where you want to use your variable called "nameVar" have to be specified in a way that JMP will properly parse them.
In the reference
distrib = New Window( namevar,
You are just dealing with a string element, and JMP will handle the simple form of just specifying the variable name......as long as the contents of the variable nameVar is a string, this will work.
In the reference
Column( As Column( namevar ) ),
You need to tell JMP to treat the variable nameVar as a column reference, which can simply be done using the As Column() function.
Your final issue is more difficult. JMP will not evaluate the SendToReport. It assumes that this is just correct code, and will not do any variable evaluations. Therefore, the Substitution() function can be used to do the evaluation and then pass the code to JMP to be run.
Eval(
Substitute(
Expr(
distrib = New Window( namevar,
Distribution(
Continuous Distribution(
Column( As Column( namevar ) ),
Normal Quantile Plot( 1 ),
Fit Distribution( Normal( Goodness of Fit( 1 ) ) )
),
SendToReport( Dispatch( {__myvar__}, "", Picture Box( 5 ), {Set Summary Behavior( "Collapse" )} ) )
)
) << Move Window( 634, 43 ) << Size Window( 807, 861 ) << Set Window Icon( "Distrib" )
),
Expr( __myvar__ ), namevar
)
);
Here is the complete script
Names Default To Here( 1 );
Clear Symbols();
pb = Page Break Box();
fileopen = "\\Kate\TIV\JMP Data.jmp";
var_name = New Window( "Variable Analysis",
<<MODAL></MODAL>
Re: More help with ModalYou're almost there. Try this code. I replaced your file with Big Class because I didn't have your dataset.
Names Default To Here( 1 );
//fileopen = "\\Kate\TIV\JMP Data.jmp";
fileopen = "$sample_data\Big Class.jmp";
dt = open(fileopen);
var_name = New Window( "Variable Analysis", <<MODAL></MODAL>
BTW it would be helpful when posting code if you used the button. Formatting wouldn't hurt either!