cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
DLC7JMP
Level I

Send Expects Scriptable Object in access or evaluation of 'Send' ,

Good Afternoon,

    I get this or similar error when trying to "write". "Record" or "save" data output

Send Expects Scriptable Object in access or evaluation of 'Send' , G << /*###*/
'Send' , G << /*###*/Save( "/homedirectory/Drug_test.txt" ) /*###*/

 

As an example I used Fitmodel example (below) for "Drug.jmp", which is a JMP example file. 

dt = Open( "$SAMPLE_DATA/Drug.jmp" ); obj = dt << Fit Model( Y( :y ), Effects( :Drug, :x ), Personality( Standard Least Squares ), Emphasis( Minimal Report ), Run ); G = obj << Get Effect PValues; Show( G ); //values show in log G << Save( "/homedirectory/Drug_test.txt");// I get the error message:Send Expects Scriptable Object in access or evaluation of 'Send' , G << /*###*/
// 'Send' , G << /*###*/Save( "/homedirectory/Drug_test.txt" ) /*###*/ // also did not work G<<savetext("/homedirectory/G.txt")

What am I doing wrong?

DLC7JMP

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Send Expects Scriptable Object in access or evaluation of 'Send' ,

What are you trying to save in this case? If you wish to save the results into a text file, you have to use Save Text File

Names Default To Here(1);

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

obj = dt << Fit Model(
	Y(:y),
	Effects(:Drug, :x),
	Personality(Standard Least Squares),
	Emphasis(Minimal Report),
	Run
);
G = obj << Get Effect PValues;

Save Text File("$TEMP/drugtest.txt", Char(G));

Web("$TEMP/drugtest.txt"); // should open in default .txt application

So in this case you are using sending incorrect message to a matrix.

-Jarmo

View solution in original post

6 REPLIES 6
jthi
Super User

Re: Send Expects Scriptable Object in access or evaluation of 'Send' ,

What are you trying to save in this case? If you wish to save the results into a text file, you have to use Save Text File

Names Default To Here(1);

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

obj = dt << Fit Model(
	Y(:y),
	Effects(:Drug, :x),
	Personality(Standard Least Squares),
	Emphasis(Minimal Report),
	Run
);
G = obj << Get Effect PValues;

Save Text File("$TEMP/drugtest.txt", Char(G));

Web("$TEMP/drugtest.txt"); // should open in default .txt application

So in this case you are using sending incorrect message to a matrix.

-Jarmo
DLC7JMP
Level I

Re: Send Expects Scriptable Object in access or evaluation of 'Send' ,

Thank you.  This works fine.  

Would you care to address why this test loop only open "analysis" windows with out "Y" variables?

This is a test for only 3 columns of data.  My goal is to run this on 4,500 columns and store the two p-values for each analyses.  

 

// Open file

dt = Open("home/AND_Counts_alphaorder_SumNorm.jmp");


// Define the range of response columns
startColumn = 31;
endColumn = 33;

// Loop over the response columns
For(col = startColumn, col <= endColumn, col++, 
	responseVar = Column(dt, col) << Get Name;
	obj = dt << Fit Model(
		Y(responseVar), 
		Effects(:mass, ::Accl_Temp_ordinal), 
		Personality(Standard Least Squares), 
		Emphasis(Minimal Report), 
		Run
	);
);

P = obj << Get Effect PValues;
Save Text File("~/Projects_AB/Ptest.csv", Char(P));
// This open 3 windows w/out "Y"
jthi
Super User

Re: Send Expects Scriptable Object in access or evaluation of 'Send' ,

I think it might be enough if you just add Eval() around your responseVar (and fix Accl_Temp_ordinal scope from :: to :). Also if you are working with that many columns, test it with much smaller amount first so you can make the script work in such a way, that you don't end up with 4500 Fit Model platforms open by accident. Below should be version of your script with the fixes I suggested

Names Default To Here(1);

dt = Open("home/AND_Counts_alphaorder_SumNorm.jmp");

// Define the range of response columns
startColumn = 31;
endColumn = 33;

// Loop over the response columns
For(col = startColumn, col <= endColumn, col++,
	responseVar = Column(dt, col) << Get Name;
	obj = dt << Fit Model(
		Y(Eval(responseVar)),
		Effects(:mass, :Accl_Temp_ordinal),
		Personality(Standard Least Squares),
		Emphasis(Minimal Report),
		Run
	);
);

P = obj << Get Effect PValues;
Save Text File("~/Projects_AB/Ptest.csv", Char(P));

 

This is a bit different type of method but maybe it can give some ideas at least on how to collect the results and how you can close the reports

Names Default To Here(1);

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

colnames = {"height", "weight"}; // many method of getting these

// Loop over the response columns
colpvals = Associative Array();

For Each({colname}, colnames,
	colname = "height"
	fm = dt << Fit Model(
		Y(Eval(colname)),
		Effects(:age, :sex),
		Personality(Standard Least Squares),
		Emphasis(Minimal Report),
		Run
	);
	pvals = fm << Get Effect PValues; 
	
	// list conversion seems to be necessary for for JSON conversion
	// and it is easiest to do here
	colpvals[colname] = As List(pvals);
	fm << close window;
	wait(0); // most likely unnecessary
);

Save Text File("$TEMP/test.json", As JSON Expr(colpvals));
// Web("$TEMP/test.json");

You might also want to consider collecting the results into JMP data table and converting that to .csv but that depends on the final result you wish to have.

-Jarmo
DLC7JMP
Level I

Re: Send Expects Scriptable Object in access or evaluation of 'Send' ,

Jarmo,

  Thanks, I try this and "Accept as Solution" if it works.

Thanks again.

Doug

DLC7JMP
Level I

Re: Send Expects Scriptable Object in access or evaluation of 'Send' ,

Hi Jarmo,
Your solution worked.
Thank you!!

However, the "Save Tex File " as a text or csv, overwrote each entry leaving only the last p-value.
Thus I combined your two files to create a JSON file, with notes at the bottom of the script to describe how to import into JMP.

See below for t

Thanks again.
Doug

Names Default To Here(1);
dt = Open("~home/mydatafile.jmp");

// Loop over the response columns
colpvals = Associative Array();

// Define the range of response columns
startColumn = 23;
endColumn = 42;

// Loop over the response columns
For(col = startColumn, col <= endColumn, col++,
	responseVar = Column(dt, col) << Get Name;
	fm = dt << Fit Model(
		Y(Eval(responseVar)),
		Effects(:mass, :Accl_Temp_ordinal),
		Personality(Standard Least Squares),
		Emphasis(Minimal Report),
		Run
	);

Pv = fm << Get Effect PValues;

// list conversion seems to be necessary for for JSON conversion
	// and it is easiest to do here
	colpvals[responseVar] = As List(Pv);
	fm << close window;
	wait(0); // most likely unnecessary
);

Save Text File("~home/Ptest4.json", As JSON Expr(colpvals));

// NOTE: open JSON file in JMP as "Data (Using Preview)" not best guess.
// top left choose "Stack" (upper right) and "Huge Guess" (under "Guess" pull down)
// File is columns of "responseVar" (data column names), rows are the two p-values
// Transposing in JMP may be desirable.

 

 

 

jthi
Super User

Re: Send Expects Scriptable Object in access or evaluation of 'Send' ,

You will have to collect the results into a list / matrix / some other data structure inside the loop and then handle saving that OUTSIDE the loop.

 

You could also first create the file as empty (or in the first cycle of the loop) with replace mode (default mode) and then append new data to the file using replace mode Save Text File(path, text|BLOB, <Mode("Replace"|"Append")>) .

 

Most likely you would want to add headers to the .csv file and the column name.

Names Default To Here(1);

filepath = "$TEMP/test.csv";

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

colnames = {"height", "weight"}; // many method of getting these

For Each({colname}, colnames,
	fm = dt << Fit Model(
		Y(Eval(colname)),
		Effects(:age, :sex),
		Personality(Standard Least Squares),
		Emphasis(Minimal Report),
		Run
	);
	pvals = fm << Get Effect PValues; 
	
	// list conversion seems to be necessary for for JSON conversion
	// and it is easiest to do here
	fm << close window;
	If(!File Exists(filepath),
		savemode = "replace";
	,
		savemode = "append"
	);
	Save Text File(filepath, Char(pvals) || "\!N", mode(savemode));

	wait(0); // most likely unnecessary
	
);

// Web(filepath);

If I were to do something like this, I would most likely collect the results into JMP table, clean it if needed and save into desired format

Names Default To Here(1);

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

colnames = {"height", "weight"}; // many method of getting these

dt_result = Empty();
For Each({colname}, colnames,

	fm = dt << Fit Model(
		Y(Eval(colname)),
		Effects(:age, :sex),
		Personality(Standard Least Squares),
		Emphasis(Minimal Report),
		Run
	);
	
	dt_p = Report(fm)[Outline Box("Effect Tests"), Table Box(1)] << Make Combined Data Table(Invisible);
	fm << close window;
	dt_p << Delete Scripts(dt_p << Get Table Script Names);
	
	If(Is Empty(dt_result),
		dt_result = dt_p;
		dt_result << Set Name("pvalues");
	,
		dt_result << Concatenate(Append to first table, dt_p);
		Close(dt_p, no save);
	);	
);

dt_result << show window(1);

jthi_0-1720023686790.png

You could then save this into a .csv using (or save it as JMP table to make sure you don't lose any data in decimals)

dt_result << Save("$TEMP/test.csv");

jthi_1-1720023748941.png

 

 

-Jarmo