Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
LaserRasin
Level II

JMP Pro 12.2 Access Violation Error (script included)

I am trying to build a custom report for viewing various data that compares the defect density from various tools.  I can sometimes have many (more than 20) tools to display, causing confusion with the spline fits.  I found a way to emphasize the spline when the tool is selected via the legend, but the function causes intermittent crashes on JMP.  

 

Here is a script that can reproduce the error, but it is intermittent -- simply select various elements of the legend, and also deselect all elements using <CTRL>

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Consumer Preferences.jmp" );
dt << Color or Mark by Column( "Gender" );


change_lines = Function( {table, ns},
    {default local},
    Wait( 0.1 );
    If( ns:nit > 1,
        If( Is Scriptable( ns:dla ),
            sd = ns:dla << Summary( Group( Column( ns:dla, ns:tool ) ), "Private" );
    
            Current Data Table( sd );
    
            sm = 0;
            For( k = 1, k <= ns:nit, k++,
                sm += Selected( Row State( k ) )
            );
    
            For( i = 1, i <= ns:nit, i++,
                c = Color To HLS( Color Of( Row State( i ) ) );
                s = Selected( Row State( i ) );
                If( Is Scriptable( c ) & N Items( c ) == 3,
                    If( sm != 0,
                        If( s == 1,
                            ns:biv << (Curve[i] << Line Color( HLS Color( c[1], 0.5 - 0.5 * c[2], c[3] ) ) << Line Width( 4 )),
                            ns:biv << (Curve[i] << Line Color( HLS Color( c[1], 0.5 + 0.5 * c[2], c[3] ) ) << Line Width( 1 ))
                        ),
                        ns:biv << (Curve[i] << Line Color( HLS Color( c[1], c[2], c[3] ) ) << Line Width( 3 ))
                    )
                );
            );
            Close( sd, nosave );
        )
    );
);

New Window( "Explore the SegFault",
    Outline Box( "Bivariate and Oneway",
        H List Box(
            biv = Bivariate(
                Y( :Name( "Salary" ) ),
                X( :Name( "Birth Year" ) ),
                SendToReport( Dispatch( {}, "Bivar Plot", FrameBox, {Frame Size( 400, 300 ), Marker Size( 3 )} ) )
            );
            biv << Group By( "Gender" );
            biv << Fit Spline( 1, standardized );
            bivr = biv << Report();
            bivr[Outline Box( 1 )] << Set Title( "Salary vs. Birth Year" );
            bivr[Picture Box( 2 )] << Delete;
            N = N Items( Associative Array( Column( dt, "Gender" ) ) << Get Keys );
            For( i = 1, i <= N, i++,
                biv << (Curve[i] << Report( 0 ))
            );
            biv;, 
                        
            ow = Oneway(
                Y( :Name( "Salary" ) ),
                X( :Name( "Gender" ) ),
                All Graphs( 0 ),
                Means and Std Dev( 1 ),
                Plot Quantile by Actual( 1 ),
                Line of Fit( 0 ),
                Box Plots( 1 ),
                Mean Error Bars( 1 ),
                Std Dev Lines( 1 ),
                Connect Means( 1 ),
                X Axis Proportional( 0 ),
                Points Jittered( 1 ),
                Points Spread( 1 ),
                SendToReport(
                    Dispatch(
                        {"Normal Quantile Plot"},
                        "Oneway QuantilePlot",
                        FrameBox,
                        {Frame Size( 350, 300 ), Marker Size( 3 ), Row Legend(
                            Column( dt, "Gender" ),
                            Marker( 1 ),
                            Marker Theme( "Paired" ),
                            Continuous Scale( 0 ),
                            Reverse Scale( 0 ),
                            Excluded Rows( 0 )
                        )}
                    )
                )
            );
            owr = ow << Report();
            owr[Table Box( 1 )] << Set Selectable Rows();
            owr[Outline Box( 1 )] << Set Title( "Proability Plot" );
            legend = owr[String Col Box( 2 )];
            legend << Sib Append( Number Col Box( "Mean", owr[Number Col Box( 2 )] << Get ) );
            legend << Sib Append( Number Col Box( "Number", owr[Number Col Box( 1 )] << Get ) );
            owr[Lineup Box( 1 )] << delete;
            owr[Picture Box( 3 )] << delete;
            owr[Outline Box( 2 )] << delete;
            owr[Outline Box( 2 )] << Set Title( "" );
            
            ns = New Namespace();
            ns:nit = N;
            ns:dla = dt;
            ns:tool = "Gender";
            ns:biv = biv;
            
            owr[Number Col Box( 2 )] << Set Row Change Function( Function( {this}, change_lines( this, ns ) ) );
            
            ow;
        )
    ) 
);

Is there anything I can do to not have this error occur?  I included the initial Wait function -- it seems to be an issue with the legend selection changing the unselected markers (I have that unselected markers are faded) and perhaps my function is also trying to change the display during an alternate update.  Increasing the wait time seems to make the error less frequent, but does not fully alleviate the situation.

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
LaserRasin
Level II

Re: JMP Pro 12.2 Access Violation Error (script included)

Thank you for all the help!  I was able to take your suggestions on not deleting the elements and make the script work with no errors.  I did not like deleting the elements, but I had not known of the handy way of hiding them.

 

Here is my original script modified so that it works fully.

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Consumer Preferences.jmp" );
dt << Color or Mark by Column( "Gender" );


change_lines = Function( {table, ns},
    {default local},
    flag = 0;
    lst = As List( table << Get Selected Rows() );
    For( i = 1, i <= ns:nit, i++,
        c = Color To HLS( Color Of( Column( ns:rs, "rsd" )[i] ) );
        If( N Items( As List( Loc( lst, i ) ) ) == 0,
            ns:biv << (Curve[i] << Line Color( HLS Color( c[1], 0.5 + 0.5 * c[2], c[3] ) ) << Line Width( 1 )),
            ns:biv << (Curve[i] << Line Color( HLS Color( c[1], 0.5 - 0.5 * c[2], c[3] ) ) << Line Width( 4 ));
            flag = 1;
        );
    );
    If( flag == 0,
        For( i = 1, i <= ns:nit, i++,
            c = Color To HLS( Color Of( Column( ns:rs, "rsd" )[i] ) );
            ns:biv << (Curve[i] << Line Color( HLS Color( c[1], c[2], c[3] ) ) << Line Width( 3 ));
        )
    );
);

New Window( "Explore the SegFault",
    Outline Box( "Bivariate and Oneway",
        H List Box(
            ns = New Namespace();
            ns:biv = Bivariate(
                Y( :Name( "Salary" ) ),
                X( :Name( "Birth Year" ) ),
                SendToReport( Dispatch( {}, "Bivar Plot", FrameBox, {Frame Size( 400, 300 ), Marker Size( 3 )} ) )
            );,
            ns:ow = Oneway(
                Y( :Name( "Salary" ) ),
                X( :Name( "Gender" ) ),
                All Graphs( 0 ),
                Means and Std Dev( 1 ),
                Plot Quantile by Actual( 1 ),
                Line of Fit( 0 ),
                Box Plots( 1 ),
                Mean Error Bars( 1 ),
                Std Dev Lines( 1 ),
                Connect Means( 1 ),
                X Axis Proportional( 0 ),
                Points Jittered( 1 ),
                Points Spread( 1 ),
                SendToReport(
                    Dispatch(
                        {"Normal Quantile Plot"},
                        "Oneway QuantilePlot",
                        FrameBox,
                        {Frame Size( 350, 300 ), Marker Size( 3 ), Row Legend(
                            Column( dt, "Gender" ),
                            Marker( 1 ),
                            Marker Theme( "Paired" ),
                            Continuous Scale( 0 ),
                            Reverse Scale( 0 ),
                            Excluded Rows( 0 )
                        )}
                    )
                )
            );
            ns:owr = ns:ow << Report();
            ns:owr[Table Box( 1 )] << Set Selectable Rows();
            ns:owr[Outline Box( 1 )] << Set Title( "Proability Plot" );
            legend = ns:owr[String Col Box( 2 )];
            legend << Sib Append( Number Col Box( "Mean", ns:owr[Number Col Box( 2 )] << Get ) );
            legend << Sib Append( Number Col Box( "Number", ns:owr[Number Col Box( 1 )] << Get ) );
            ns:owr[Lineup Box( 1 )] << delete;
            ns:owr[Picture Box( 3 )] << delete;
            ns:owr[Outline Box( 2 )] << delete;
            ns:owr[Outline Box( 2 )] << Set Title( "" );
            
            ns:dla = dt;
            ns:tool = "Gender";
            ns:biv = ns:biv;
            
            ns:rs = ns:dla << Summary( Group( Column( ns:dla, ns:tool ) ), "Private" );
            ns:rs << New Column( "rsd", Row State, Set Formula( Color State( Color Of( Row State() ) ) ) );
        
            ns:nit = N Items( legend << Get );

            ns:biv << group by( Column( ns:dla, ns:tool ) );
            ns:biv << fit spline( 1, standardized );
            ns:bivr = ns:biv << Report();
            ns:bivr[Outline Box( 1 )] << Set Title( "Trend Chart" );
            ns:bivr[Picture Box( 2 )] << Visibility( "Collapse" );
            isdone = 0;
            For( i = 1, i <= ns:nit, i++,
                ns:biv << (Curve[i] << Report( 0 ));
                ns:bivr[List Box( 4 + i )] << Visibility( "Collapse" );
            );
            
            ns:owr[Number Col Box( 2 )] << Set Row Change Function( Function( {this}, change_lines( this, ns ) ) );
            
            
        )
	
    ) 
	
);

View solution in original post

5 REPLIES 5
Highlighted
David_Burnham
Super User

Re: JMP Pro 12.2 Access Violation Error (script included)

For what it's worth, I've not been able to reproduce the access violation (with or without the wait).  I've tried with various versions including 12.2.

 

If I was experiencing this problem I would look to refactor the code.  In particular, my view is that a New Window function should be used to render display boxes and whilst JMP might tolerate the insertion of JSL it is ugly, not necessary and potentially problemmatic.  So for example, all of the messages sent to the biv report I would do after the New Window definition.

 

-Dave
Highlighted
gzmorgan0
Super User

Re: JMP Pro 12.2 Access Violation Error (script included)

I was able to reproduce the Access Violation and sent the report to JMP with the script and the blog reference.

I selected M then I selected F and I was dumped.

 

I agree with David.  

 

I found some strange syntax, made a few script changes and have a couple comments:

  • You have the objects biv and ow defined and embedded in a Window. I do not understand the  biv; , and ow, maybe JMP ignores them, but they are unnecessary and I suggest you remove them.
  • Be careful deleting display boxes, especially scriptable objects. From experience that makes the display unstable.  I believe when you use the delete as below, the attached script no longer matches the display.  For example, you had the statement below to remove the report means and std dev, when ow << Means and Std Dev(0); would have the same effect and then the script and the report match. 
                owr[Outline Box( 2 )] << delete;
  • After making a few more changes, I could not reproduce the Access Violation: (1)removed the deletion of the LineupBox; (2) made the summary table persist; (3) just because, made the main table current before leaving the handler function. I think the recreation of the summary table for each selection might be the intermittent issue. I believe in JMP 11 and maybe JMP 12, the table deletions were put on a stack.

I attached a modification of your script and simpler script, previously posted. It uses the legend and a summary table and a rowstate handler. It does not "fade" the unselected splines as your script did.  

 

I cannot guarantee, the access violation won't occur. Reply, if it still occurs. 

 

Highlighted

Re: JMP Pro 12.2 Access Violation Error (script included)

I will add that deleting content from a platform report can often lead to problems.  I would suggest:

 

  1. Use a platform option if it exists - this is what Georgia did with
    ow << Means and Std Dev(0);
  2. When platform options are not available, you can use the box<<Visibility("Collapse") message instead of deleting. This behaves similar to an IfBox() in skipping over portions of the report for layout and drawing.

In addition to avoiding the crash, one advantage of these approaches is that they will be remembered in scripts.  If you modify one of your platforms interactively and use Save Script To Script Window, the customizations will be included in the script.  This may also be important if you want to add filters, which will also cause the platforms to regenerate from the script.

Highlighted
LaserRasin
Level II

Re: JMP Pro 12.2 Access Violation Error (script included)

Thank you for all the help!  I was able to take your suggestions on not deleting the elements and make the script work with no errors.  I did not like deleting the elements, but I had not known of the handy way of hiding them.

 

Here is my original script modified so that it works fully.

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Consumer Preferences.jmp" );
dt << Color or Mark by Column( "Gender" );


change_lines = Function( {table, ns},
    {default local},
    flag = 0;
    lst = As List( table << Get Selected Rows() );
    For( i = 1, i <= ns:nit, i++,
        c = Color To HLS( Color Of( Column( ns:rs, "rsd" )[i] ) );
        If( N Items( As List( Loc( lst, i ) ) ) == 0,
            ns:biv << (Curve[i] << Line Color( HLS Color( c[1], 0.5 + 0.5 * c[2], c[3] ) ) << Line Width( 1 )),
            ns:biv << (Curve[i] << Line Color( HLS Color( c[1], 0.5 - 0.5 * c[2], c[3] ) ) << Line Width( 4 ));
            flag = 1;
        );
    );
    If( flag == 0,
        For( i = 1, i <= ns:nit, i++,
            c = Color To HLS( Color Of( Column( ns:rs, "rsd" )[i] ) );
            ns:biv << (Curve[i] << Line Color( HLS Color( c[1], c[2], c[3] ) ) << Line Width( 3 ));
        )
    );
);

New Window( "Explore the SegFault",
    Outline Box( "Bivariate and Oneway",
        H List Box(
            ns = New Namespace();
            ns:biv = Bivariate(
                Y( :Name( "Salary" ) ),
                X( :Name( "Birth Year" ) ),
                SendToReport( Dispatch( {}, "Bivar Plot", FrameBox, {Frame Size( 400, 300 ), Marker Size( 3 )} ) )
            );,
            ns:ow = Oneway(
                Y( :Name( "Salary" ) ),
                X( :Name( "Gender" ) ),
                All Graphs( 0 ),
                Means and Std Dev( 1 ),
                Plot Quantile by Actual( 1 ),
                Line of Fit( 0 ),
                Box Plots( 1 ),
                Mean Error Bars( 1 ),
                Std Dev Lines( 1 ),
                Connect Means( 1 ),
                X Axis Proportional( 0 ),
                Points Jittered( 1 ),
                Points Spread( 1 ),
                SendToReport(
                    Dispatch(
                        {"Normal Quantile Plot"},
                        "Oneway QuantilePlot",
                        FrameBox,
                        {Frame Size( 350, 300 ), Marker Size( 3 ), Row Legend(
                            Column( dt, "Gender" ),
                            Marker( 1 ),
                            Marker Theme( "Paired" ),
                            Continuous Scale( 0 ),
                            Reverse Scale( 0 ),
                            Excluded Rows( 0 )
                        )}
                    )
                )
            );
            ns:owr = ns:ow << Report();
            ns:owr[Table Box( 1 )] << Set Selectable Rows();
            ns:owr[Outline Box( 1 )] << Set Title( "Proability Plot" );
            legend = ns:owr[String Col Box( 2 )];
            legend << Sib Append( Number Col Box( "Mean", ns:owr[Number Col Box( 2 )] << Get ) );
            legend << Sib Append( Number Col Box( "Number", ns:owr[Number Col Box( 1 )] << Get ) );
            ns:owr[Lineup Box( 1 )] << delete;
            ns:owr[Picture Box( 3 )] << delete;
            ns:owr[Outline Box( 2 )] << delete;
            ns:owr[Outline Box( 2 )] << Set Title( "" );
            
            ns:dla = dt;
            ns:tool = "Gender";
            ns:biv = ns:biv;
            
            ns:rs = ns:dla << Summary( Group( Column( ns:dla, ns:tool ) ), "Private" );
            ns:rs << New Column( "rsd", Row State, Set Formula( Color State( Color Of( Row State() ) ) ) );
        
            ns:nit = N Items( legend << Get );

            ns:biv << group by( Column( ns:dla, ns:tool ) );
            ns:biv << fit spline( 1, standardized );
            ns:bivr = ns:biv << Report();
            ns:bivr[Outline Box( 1 )] << Set Title( "Trend Chart" );
            ns:bivr[Picture Box( 2 )] << Visibility( "Collapse" );
            isdone = 0;
            For( i = 1, i <= ns:nit, i++,
                ns:biv << (Curve[i] << Report( 0 ));
                ns:bivr[List Box( 4 + i )] << Visibility( "Collapse" );
            );
            
            ns:owr[Number Col Box( 2 )] << Set Row Change Function( Function( {this}, change_lines( this, ns ) ) );
            
            
        )
	
    ) 
	
);

View solution in original post

Highlighted

Re: JMP Pro 12.2 Access Violation Error (script included)

JMP Technical Support has opened a defect for this issue and expect it to be resolve in a future version of JMP.

Article Labels

    There are no labels assigned to this post.