Help with a simple if statement

Posted by takem on
URL: http://imagej.273.s1.nabble.com/Help-with-a-simple-if-statement-tp3684215.html

I am writing a script that asks the user a Yes/No question. If the user selects "Yes", the script will run through a if statement, otherwise, it will skip the if statement:

choices = newArray("Yes", "No");
Dialog.create("Select choice");
Dialog.addMessage("Are there any areas that need to be removed?");
Dialog.addChoice("-->", choices);
Dialog.show();
choice = Dialog.getChoice();
 
if  (choice == "Yes") {
title = "Removal";
msg = "After selecting area to be removed with the brush tool, click \"OK\".";
waitForUser(title, msg);

roiManager("add");

Dialog.create("Select choice");
Dialog.addMessage("Are there any more areas that need to be removed?");
Dialog.addChoice("-->", choices);
Dialog.show();
choice = Dialog.getChoice();
}

If at the end of the if statement, the user selects "Yes" again, I want it to run through the if statement one more time. However, my script continues no matter what the user chooses. How can I loop it back to the if statement?