cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Learn how to build custom Python data connectors and further customize JMP’s Data Connector Framework with the Python Data Connector Demo, available now in the JMP Marketplace!
  • See how to create experiments to support product design and ID useful product features. Register for June 12 webinar, 2pm US Eastern Time.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
asdf
Level I

Scriptable[] or 'send expects scriptable object'

Hi,

I've tried many methods of trying to select specific rows with PM#=2 and  Logistic#=1 in my pre-filtered table, but I either get a 'Send expects scriptable object' message, a 'Scriptable[]' and then script termination, or an endless loop.  Can someone please help with what is inappropriate with the syntax that I cannot program the row selection?  Thanks!

 

 

lamstationfile=Pick File("choose file","$Documents" );
dt=Open(lamstationfile,
Import Settings(End Of Field( Tab ),Scan Whole File( 1 ), Column Names Start(7 ),Data Starts( 8),));
dt = Current Data Table();

//find data rows
w=NRow(dt);
dt<<Select Where(:Time=="NUM_DATA_ROWS")<<Label(1);
d=dt<<Get Selected Rows;
Show(d);
dt<<Select Where(Row()>(d-1));
dt2=dt<<Subset( Selected Rows(1), Selected columns only(0));
dt<<Select Where(Row()>(d-1))<<Delete Rows;
// Change first two columns to numeric data
Column(dt,1)<< Data Type (Numeric); Column(dt,1)<<Modeling Type("Continuous");
Column(dt,2)<< Data Type (Numeric); Column(dt,2)<<Modeling Type("Continuous");
 

nw= New Window( "What PM?",<<Modal,<<Bring Window To Front,
V List Box( Text Box( "PM#"), pm_in = Text Edit Box("PM#", <<Justify Text (Center)), Spacer Box(Size(25,25))),
H List Box( Button Box("OK", pm= pm_in << Get Text();), Button Box("Cancel", nw<<Close Window)));
nw= New Window( "What Logistic?",<<Modal,<<Bring Window To Front,
V List Box( Text Box( "Logistic#"), wafer_in =Text Edit Box("Logistic#"), Spacer Box(Size(25,25))),
H List Box( Button Box("OK", logis= wafer_in << Get Text();), Button Box("Cancel", nw<<Close Window)));
//take out uneccessary PM data
Show("PM"|| pm);
ColNames = dt << Get Column Names();
colstrings = char(colnames);
match = regex(colstrings, "PM"|| pm);
//Show(colstrings);
found_list={};
close(dt2,no save);
//how can I have it with 2 dt open?
for (i = 1, i <= nitems(ColNames), i++,
if (contains(ColNames[i], match),
ColNames[i]<<Set Selected(1)
//insertinto(found_list, ColNames[i]);
);
);
Column(dt,1)<<Set Selected(1);
//For found_list<<Set Selected(1);
//Show(found_list);
dt3=dt<<Subset( Selected Rows(0), Selected columns only(1));

Num(logis);
Show(logis);
//Logistics column is the last in the table
clos=NCol(dt3);
Show(clos);
Show( Column( dt3, clos )[2] );
 
//dt3<<Get Rows Where(:Column(clos)==logis);  //Method #1
 
dt3<<Selet Where(:Column( dt3, clos ) == Num( logis ));   //Method#2
 
//For(i=1, i=NRows(dt3), i++,    //Method#3
//If( Column( dt3, clos )[i] == Num( logis ),
// Column( dt3, clos )[i] << Set Selected( 1 ));  );
 
 
//For Each Row(If( :Column( dt3, clos ) == Num( logis ), :Column( dt3, clos ) << Set //Selected(1));  //Method#4

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Scriptable[] or 'send expects scriptable object'

I thought that @uday_guntupalli code should work, however in 13.2.1 it would not(strange).  However, using As Column() instead of Column() allowed your specific code to work

Names Default To Here( 1 );
dt3 = Open( "$SAMPLE_DATA/Big Class.jmp" );
logis = "55";
clos = "Height";
dt3 << Select Where( As Column( dt3, clos ) == Num( logis ) );
Jim

View solution in original post

8 REPLIES 8
uday_guntupalli
Level VIII

Re: Scriptable[] or 'send expects scriptable object'

@asdf : 
    Attachment (.zip) file is empty - so your data was not provided to test your code and see you error to troubleshoot . 
   In the absence of the actual data you are working with - here lets look at this example . 

dt = Open( "$SAMPLE_DATA/Air Traffic.jmp" );

dt << Select Where(:Airline == "Delta" & :Event == "Arrive"); 

  As you can see - you can select rows where two different conditions on two different columns are being met. 

  In your case - if the PM#=2 and  Logistic#=1 refer to 2 different tables - then you need to join the tables based on common columns for what you are after. 

  If its not either - please provide actual sample data .

Best
Uday
asdf
Level I

Re: Scriptable[] or 'send expects scriptable object'

Sorry.  The data is now appropriately attached.

txnelson
Super User

Re: Scriptable[] or 'send expects scriptable object'

Here is a script that covers the first issue in your data table, selecting row after finding "NUM_DATA_ROWS:

lamstationfile = Pick File( "choose file", "$Documents" );
dt = Open( lamstationfile, Import Settings( End Of Field( Tab ), 
Scan Whole File( 1 ), Column Names Start( 7 ), Data Starts( 8 ), ) );
dt = Current Data Table();

//find data rows
w = N Row( dt );
dt << Select Where( :Time == "NUM_DATA_ROWS" ) << Label( 1 );
d = dt << Get Selected Rows;
Show( d );
// A matrix is returned from << Get Selected Rows, so you need to reference d[1]
dt << Select Where( Row() > (d[1] - 1) );
dt2 = dt << Subset( Selected Rows( 1 ), Selected columns only( 0 ) );
dt /*<< Select Where( Row() > (d - 1) )*/ << Delete Rows;
// Change first two columns to numeric data
Column( dt, 1 ) << Data Type( Numeric );
Column( dt, 1 ) << Modeling Type( "Continuous" );
Column( dt, 1 ) << format("hr:m:s");
Column( dt, 2 ) << Data Type( Numeric );
Column( dt, 2 ) << Modeling Type( "Continuous" );

Concerning your selection of columns and then subsetting, I would suggest that you use the builtin column selection tool, "Columns Viewer" rather than building your own selection tool.

dt << Columns Viewer;
Jim
asdf
Level I

Re: Scriptable[] or 'send expects scriptable object'

Sorry, I should have been more clear.  The problem I am having is with the end of my code after I've created a third data table dt3.  Everything before the last active line of code works fine [getting rows and columns in first data table dt, setting the inputs PM#=2 and Logistic#=1 are fine ].  I just cannot select several rows in dt3 where Logistic# =1 . 

 

I've tried several different methods as noted in the code excerpt below, but I either get code terminated with 'Scriptable[]' note or 'Send expects scriptable object' error.  I'm not sure where in the below code is preventing it from running appropriately.

  

 

 

//dt3<<Get Rows Where(:Column(clos)==logis);  //Method #1
 
dt3<<Selet Where(:Column( dt3, clos ) == Num( logis ));   //Method#2
 
//For(i=1, i=NRows(dt3), i++,    //Method#3
//If( Column( dt3, clos )[i] == Num( logis ),
// Column( dt3, clos )[i] << Set Selected( 1 ));  );
 
 
//For Each Row(If( :Column( dt3, clos ) == Num( logis ), :Column( dt3, clos ) << Set //Selected(1));  //Method#4

 

uday_guntupalli
Level VIII

Re: Scriptable[] or 'send expects scriptable object'

dt3 <<Select Where(:Column( dt3, clos ) == Num( logis )); // There is a typo to start with
Best
Uday
txnelson
Super User

Re: Scriptable[] or 'send expects scriptable object'

I thought that @uday_guntupalli code should work, however in 13.2.1 it would not(strange).  However, using As Column() instead of Column() allowed your specific code to work

Names Default To Here( 1 );
dt3 = Open( "$SAMPLE_DATA/Big Class.jmp" );
logis = "55";
clos = "Height";
dt3 << Select Where( As Column( dt3, clos ) == Num( logis ) );
Jim
asdf
Level I

Re: Scriptable[] or 'send expects scriptable object'

Thank you for your response. I think that typo only happened when I was transferring the code to the Online Discussion. There wasn't a typo on my computer, otherwise I would have gotten a different error. Also, Method#1, #3, and #4 didn't work for me either. Not sure why.

@uday_guntupalli wrote:
dt3 <<Select Where(:Column( dt3, clos ) == Num( logis ));
uday_guntupalli
Level VIII

Re: Scriptable[] or 'send expects scriptable object'

The data that you attached is a file , I am unable to open .
Can you just provide a small subset of the table you are trying to work with ?
One reason I can think of as to why your row selection doesn't work .

Besides providing sample data set , can you try this ?
dt = Current Data Table();
And then run your selection where dt is the data table you are working with .
If JMP doesn't recognize or has lost the reference of the data table , then irrespective of your approach - the row selection operation will not work .
Best
Uday

Recommended Articles