Commenting in Groovy
Short and sweet - any characters preceded by // will be ignored by the script compiler - this allows you to place notes to yourself or users of your code. A month or year from now you may not remember why you did something, so comment early, comment often, and comment more clearly than I usually do.
//This is a comment on a line /* The comment in this format starts here but keeps going on each subsequent line until we reach */ This is no longer a comment and will throw an error.
One further point unrelated to commenting - any code you copy from other sources, especially the forum, that is not formatted appropriately will throw an error if there is a quotation mark in it.
If you do post on the forum, help us help you! Format your code appropriately!
Using the preformatted text option as shown second, will be QuPath friendly.
One further option is using dialog popups, as shown in the code taken from a simple example here. These are great when you really want to get a user's attention, but may be less useful for scripts intended to be run "For Project."
def obj = getSelectedObject() if (obj == null) { Dialogs.showErrorMessage("Selection", "Select an annotation first!") return } removeObjects(obj.getChildObjects(), false)