Image J / FIJI saving null value to the ImageJ clip board

I am quite new to ImageJ and FIJI
I have written a macro (below) in FIJI to identify particles in an image and to save the results to the Fiji clipboard so I can paste them into a spreadsheet.

It works fine as long as there are particles in the Region of Interest. However, if there are no particles in the ROI it either displays an error message and adds the line number to the clipboard or it adds nothing to the clipboard and copies whatever is on the main system clipboard to the FIJI clipboard. This can result in the user copying the wrong data into the spreadsheet.

I would like to change the macro so that if there are no aggregates in the ROI it will clear the clipboard and either copy nothing into the clipboard or copy text such as ‘no aggregates’ into the clipboard so that it is obvious to the user that there are no aggregates in the ROI.

I would be very grateful for suggestions of how to do this please

macro "FS_AM738 [j]" {
// clear previous results
run("Clear Results");
// remember the original hyperstack

original_image = getImageID();
title = getTitle();
dotIndex = indexOf(title, ".");
basename = substring(title, 0, dotIndex);
path = getDirectory("image");
image = "image_" + title + ".tiff";
threshold =  "threshold_" + title + ".tiff"; 
aggregates =  "aggregates_" + title + ".tiff"; 
threshold_copy =  "threshold_copy _" + title + ".tiff"; 
aggregates_copy =  "aggregates_copy_" + title + ".tiff"; 
tileE = basename + "_E.tiff";
inverted_aggregates =  "inverted_aggregates " + title + ".tiff"; 
composite = "composite " + title + ".tiff"; 
run("Duplicate...", "title=&image");
run("Duplicate...", "title=&threshold");


setThreshold(0, 160);

//setThreshold(0, 160);

setOption("BlackBackground", false);
run("Convert to Mask");
run("Analyze Particles...", "size=2-Infinity circularity=0.2-1.00 show=Masks display clear summarize");
run("Duplicate...", "title=&aggregates_copy");
run("Merge Channels...", "c2=&aggregates c4=&image create ");
run("RGB Color");

Have you considered using any of the ROI or ROI manager tools to do this? just ctrl+F search them on theBuilt In Functions page and they should pop right up. might be useful for you.

Also, have you thought about using a conditional statement (if/else) against the number of lines in your results table? it would let you return a message when you have an image with no particles, and shouldn’t throw an error.

thanks I will try those options