Hi Andrew,
You can enclose your wait command inside a while loop that checks for a region existing:
while(regionType()<0){
waitForUser("Select Area");
}
regionType() returns -1 if there's no region so you can't escape the loop without drawing one.
Note that if there's a region on the image before this point then the wait command won't execute at all so you may need to put run("Select None"); beforehand
Hope this helps,
-Lachie
----- Original Message -----
From: "Andrew Sanchez" <
[hidden email]>
To:
[hidden email]
Sent: Friday, 3 July, 2015 7:48:48 AM
Subject: Looping waitForUser if correct action not taken
If I accidentally click 'OK' before making a selection, it appears I would
have to restart the macro because an area selection is required for the rest
of the macro to run, resulting in the message "area selection required".
This is inconvenient because I am working with folders containing 160
images, and the macro starts with the first file in the directory. Is there
a way to prevent this from happening? Perhaps I can add something that will
run waitForUser again if a selection is not made?
Here is the part of my macro I am referring to
setTool("oval");
waitForUser("Select areas","Hold shift while drawing circle, then click
'OK'");
run("Crop");
setBackgroundColor(255, 255, 255);
run("Clear Outside");
run("Measure");
Thank you!
--
View this message in context:
http://imagej.1557.x6.nabble.com/Looping-waitForUser-if-correct-action-not-taken-tp5013402.htmlSent from the ImageJ mailing list archive at Nabble.com.
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html______________________________________________________________________
The information in this email is confidential and intended solely for the addressee.
You must not disclose, forward, print or use it without the permission of the sender.
______________________________________________________________________
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html