cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
vishwasanj
Level V

data filter for loop

Hi,

I am fairly new to scripting. I understand for loop but I need a little bit of help here.

I am not able to find the for loop example for a data filter in the scripting guide. If someone could help me with the syntax, that would be great.

 

What I am trying to do is, I have a treemap and I need to construct a 'for' loop with the data filter table to get the graph outputs saved as .png file automatically.

 

I have attached a figure. For example, condition 1: wafer 11, choosing all Vpp trimset for 25C and Formula NO (1 graph)

                                                               condition 2: wafer 12, choosing all Vpp trimset for for 85C (0,11111)and  and Formula NO (1 graph)

                                                               condition 3: plotting each trimset value for all for wafer 11( 9 graphs) and wafer 12 with YES (2 graphs)

I am able to do it if I do it one by one in a code, but not together.

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
David_Burnham
Super User (Alumni)

Re: data filter for loop

The example I give below contains code that will skip combinations for which there are no rows

 

http://www.pega-analytics.co.uk/blog/scripting-data-filters/

 

 

-Dave

View solution in original post

13 REPLIES 13

Re: data filter for loop

You might try @Craige_Hales response in this question- link.  Rather than trying to work with the local data filter, adding a where clause into your platform call is probably a more elegant way to do what you're after.

vishwasanj
Level V

Re: data filter for loop

I belive that example was for a fit y by x distribution. I am trying to do it for a treemap in graph builder. I will give it a shot. Thank you M_Anderson

Re: data filter for loop

It is, but graph builder also accepts where clauses.

Best,

M
Craige_Hales
Super User

Re: data filter for loop

dt = Open( "$sample_data/big class.jmp" );
ages = Data Table( "big class" ) << Summary( Group( :age ), Freq( "None" ), Weight( "None" ) );
sexes = Data Table( "big class" ) << Summary( Group( :sex ), Freq( "None" ), Weight( "None" ) );
Delete Directory( "$temp/myPics" );
Create Directory( "$temp/myPics" );
For( iage = 1, iage <= N Rows( ages ), iage++,
thisAge = ages:age[iage];
For( isex = 1, isex <= N Rows( sexes ), isex++,
thisSex = sexes:sex[isex];
Eval(
Eval Expr(
gb = dt << Graph Builder(
Size( 508, 438 ),
Show Control Panel( 0 ),
Variables( X( :weight ), Y( :height ) ),
Elements( Points( X, Y, Legend( 5 ) ) ),
where( age == Expr( thisAge ) & sex == Expr( thisSex ) )
)
)
);
parentBox = (Report( gb ) << parent)<<parent;
picture = parentBox << getpicture;
picture << saveImage( "$temp/myPics/age" || Char( thisAge ) || "sex" || Char( thisSex ) || ".png", "png" );
// optional: Open( "$temp/myPics/age" || Char( thisAge ) || "sex" || Char( thisSex ) || ".png" );
gb << closewindow;
);
);
Close( ages, "nosave" );
Close( sexes, "nosave" );
Show( Files In Directory( "$temp/myPics" ) );

It looks like you might need to grab the "grandparent" displaybox for graph builder; the parent)<<parent does that to reach out to the where clause in the display tree.

screen capture of large icons of graphs saved by scriptscreen capture of large icons of graphs saved by script

 

Craige
vishwasanj
Level V

Re: data filter for loop

Thank you Craige
vishwasanj
Level V

Re: data filter for loop

Hi Craige,

I did implement and I started expaning on the for loops.

I got this error, Send Expects Scriptable Object{630} in access or evaluation of 'Send' , Report( gb ) << /*###*/parent/*###*/... Is it because there are too many windows open and JSL doesn't realize which gb I am referring to?
txnelson
Super User

Re: data filter for loop

From your comment I believe that you have a misunderstanding of Craig's script that he posted.  In his code, there is never more than 1 instance of the graph builder open at a time. The pointer to the graph builder, "gb" points to the current execution of the graph builder.  It creates a picture object of the Graph Builder output, saves it to a file.  Then it CLOSES the graph builder object (gb<<closewindow) and then loops back and starts all over again,

 

If your code is generating multile graph builders, and each one uses "gb" as the handle pointing to the graph builder instance, "gb" is only pointing to the last graph builder instance.

Jim
Craige_Hales
Super User

Re: data filter for loop

right.  or gb was never set, or gb is already closed.

You can use 

 show(type(gb));
showproperties(gb);

in your script to get some information about the object.  You should see something like this in the log:

Type(gb) = "Scriptable";
Show Control Panel [Boolean] [Default On] (Displays or hides the control panel.)
Show Legend [Boolean] [Default On] (Displays or hides the legend to the right of the graph.)
Legend Position [Enum] {Right, Bottom, Inside Left, Inside Right}
Legend Settings [Action](Opens a dialog to modify the properties of the legend.)
Continuous Color Theme [Action](Se .... < a lot more follows>

In JMP, a "scriptable" object is an object like a DisplayBox or a platform (or a lot of other possibilities) that has methods.  A DisplayBox has a method named parent that is used with the << operator to get the DisplayBox's parent box.  The ShowProperties function lists all the methods the DisplayBox knows about.  You can see these in the scripting index (under the help menu) in an easier to read form.

When your script says "expecting a scriptable..." it means the gb variable does not hold a scriptable object.

 

 

Craige
Craige_Hales
Super User

Re: data filter for loop

and in the example code, gb is a platform object.  the report() function asks the platform object for the DisplayBox that holds the platform's visible report.  The platform is unaware that there are more DisplayBoxes around it.  You have to use the <<parent method, twice, to navigate up to the DisplayBox that holds the where clause.

Craige