Subscribe Bookmark RSS Feed

Select Columns - JMP10

robot

Community Trekker

Joined:

Feb 27, 2012

Hi,

I am having trouble selecting columns in JMP10.  This example is lifted strait from the JMP10 Scripting Guide:

/*

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

cc = dt << Get Column Names( Continuous );

ncols = N Items( cc );

For( i = 1, i <= ncols, i++,

  cc << Set Selected( 1 )

);

*/

However, it generates the following error in the log:

/*

Send Expects Scriptable Object in access or evaluation of 'Send' , cc << Set Selected( 1 )

In the following script, error marked by /*###*/

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

cc = dt << Get Column Names( Continuous );

ncols = N Items( cc );

For( i = 1, i <= ncols, i++,

  cc <<  /*###*/Set Selected( 1 ) /*###*/

);

*/

Any suggestions?

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

Ha, if I copy your script into JMP 10.0.2 and run it, it works! Without error!

Perhaps you have multiple tables open and JMP is getting confused as to which is the 'current' one. That, or it is intepretting as a row reference.

Anyhow - ask yourself - what does variable cc contain?  It is a list, of column references.

show(cc);

cc = {height, weight};

but then run this:

show(cc[1]);

show(cc[2]);

cc[1] = :height;

cc[2] = :weight;

So your loop, is, in turn, running these commands:

:height <<  set selected(1);

:weight << set selected(1);

I think the use of the As Column(dt, name) function is clearer and more foolproof:

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

cc = dt << Get Column Names( Continuous );

show (cc);

ncols = N Items( cc );

For( i = 1, i <= ncols, i++,

  as column(dt, cc) << Set Selected( 1 )

);

The following will also work:

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

cc = dt << Get Column Names( Continuous );

show (cc);

ncols = N Items( cc );

For( i = 1, i <= ncols, i++,

  y=cc;

  dt:y << Set Selected( 1 )

);

2 REPLIES
Solution

Ha, if I copy your script into JMP 10.0.2 and run it, it works! Without error!

Perhaps you have multiple tables open and JMP is getting confused as to which is the 'current' one. That, or it is intepretting as a row reference.

Anyhow - ask yourself - what does variable cc contain?  It is a list, of column references.

show(cc);

cc = {height, weight};

but then run this:

show(cc[1]);

show(cc[2]);

cc[1] = :height;

cc[2] = :weight;

So your loop, is, in turn, running these commands:

:height <<  set selected(1);

:weight << set selected(1);

I think the use of the As Column(dt, name) function is clearer and more foolproof:

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

cc = dt << Get Column Names( Continuous );

show (cc);

ncols = N Items( cc );

For( i = 1, i <= ncols, i++,

  as column(dt, cc) << Set Selected( 1 )

);

The following will also work:

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

cc = dt << Get Column Names( Continuous );

show (cc);

ncols = N Items( cc );

For( i = 1, i <= ncols, i++,

  y=cc;

  dt:y << Set Selected( 1 )

);

robot

Community Trekker

Joined:

Feb 27, 2012

Thanks blackeneth,

You are correct.  My code is part of a larger script with multiple tables open and JMP was getting confused.  "As Column(dt, name)" did the trick.  Thanks!