String.copyResults - not copying new columns?

The macro below illustrates that user-added columns are not retrieved with the String.copyResults command. However, String.getResultsHeadings retrieves the heading of these user-added columns. I wonder if this is a bug in String.copyResults or just the way it is.

run("Blobs (25K)");
name = getTitle;

run ("Select All");
run("Measure");

setResult("Image", 0, name);// add a new column "Image" to the Results table and writes blobs.gif to the first row

print(String.getResultsHeadings);// write Results column headings to the log window. The column header "Image" is retrieved
print("-------------------------------");

// copy the Results table and write to log window. Column "Image" is missing
	String.copyResults; 
	alles=String.paste;
	print(alles); 

It could be a bug, but I suspect it behaves exactly as when you copy rows manually from the Results table. Have you looked at the status of the “Copy row numbers” checkbox in Edit>Options>Input/Output… ? I’m guessing its status will influence the behavior of built-in macro functions.

I checked the Input/Output options just now: they don´t change anything concerning the described behaviour

It was worth trying. Just ran your snippet in IJ 1.51h10: With the Results table closed, the missing column is missing the first time you run the macro, but it is listed when one runs it more than once: i.e., the missing column will appear the second time you run your macro. This suggests there is nothing wrong with the String.copyResults macro function.

I think you just forgot to call updateResults() when you appended the new column. Here is your snippet revised, that seems to work as expected:


run("Blobs (25K)");
name = getTitle();
run("Measure");
setResult("Image", 0, name); // add a new column "Image" to the Results table and write "blobs.gif" to the first row
updateResults(); // update table
print(String.getResultsHeadings); // write Results column headings to the log window. The column header "Image" is retrieved

print("-------------------------------");
// copy the Results table and write to log window. Column "Image" is present as expected
String.copyResults; 
alles = String.paste;
print(alles);
2 Likes

Thank you @tferr. I should have asked this earlier ! (before I started to “invent” solutions to circumvent this problem).

1 Like