We’re asking you to select a content label when starting a new topic in the Discussions area. Read more to find out why.
Choose Language Hide Translation Bar
Highlighted
Level III

## Scripting: how to close an analysis within a For loop?

In the simple script below, how can I close each of the Bivariate analysis after I capture its report?

Names Default to Here (1);

dt = Current Data Table ();

m = {};

m1 = [];

m2 = [];

For (i=6, i<= N Col (dt), i++,

bv = Bivariate(

Y( Column (i)),

X( :mRSS ),

Density Ellipse( 0.95, {Line Color( {213, 72, 87} )} ),

invisible

);

bvr = bv << report;

insert into (m, Column Name (i));

m1 = m1 || bvr [Outline Box (1)] [ Number Col Box (3)] [1];

m2 = m2 || bvr [Outline Box (1)] [ Number Col Box (4)] [1];

);

New Table ("CORRELATION",

New column ("Symbol", character, set values (m)),

New column ("Correlation", numeric, set values (m1)),

New column ("P Value", numeric, set values (m2)),

);

1 ACCEPTED SOLUTION

Accepted Solutions
Super User

## Re: Scripting: how to close an analysis within a For loop?

bv << close window;

4 REPLIES 4
Super User

## Re: Scripting: how to close an analysis within a For loop?

bv << close window;

Highlighted
Super User

## Re: Scripting: how to close an analysis within a For loop?

MS is correct, however, other issues exist in your script.  I have taken the liberty to modify your script to make it work

Names default to here(10);

dt = Current Data Table ();

m = {};

m1 = [];

m2 = [];

For (i=6, i<= N Col (dt), i++,

bv = Bivariate(

Y( Column (i)),

X( :mRSS),

Density Ellipse( 0.95, {Line Color( {213, 72, 87} )} ),

invisible

);

bvr =report( bv );

insert into (m, Column Name (i));

m1 = m1 || ((bvr [Outline Box (1)] [ Number Col Box (3)])<<get) [1];

m2 = m2 || ((bvr [Outline Box (1)] [ Number Col Box (4)])<<get) [1];

bv << close window;

);

New Table ("CORRELATION",

New column ("Symbol", character, set values (m)),

New column ("Correlation", numeric, set values (m1)),

New column ("P Value", numeric, set values (m2)),

);

Jim
Highlighted
Level III

## Re: Scripting: how to close an analysis within a For loop?

Hi Jim,

Thanks for cleaning up my simple script. Could you explain to me how the "<< get" command works? I noticed that my simple script worked well by simply adding the "bv << close window" command and leaving out the "<< get" command.

Also, you wrote  "Names default to here(10);" I have to admit that I have always left this command with the value 1 without thinking that it could be a larger number. What does the "10" value do to the script?

Thank you for your help.

Sincerely,

Thierry

Highlighted
Super User

## Re: Scripting: how to close an analysis within a For loop?

I will first explain the "Names Default to Here(10);"  Quite simply, it is a typo.  It should be a "1".

The "<< get" is the message, when sent to the object it is pointing to, to retrieve the values.

bvr [Outline Box (1)] [ Number Col Box (3)])<<get

retrieves Number Col Box(3)'s column of numbers into a list.

It is a similar to the form of retrieving the text from Outline Box(1) by specifying:

bvr [Outline Box (1)]<<get title

Jim