There is no dialogue that will block the code until there is input. Such a user interface component does not exist. Structuring your code as a loop of this kind will not work.
Display the first Alert. Use the commandAction() event of the Alert's CommandListener to perform the action (assuming the Command is "yes"). At the end of performing the action, display the next Alert (setCurrent()).
Something like:
Code:
private static final Command acceptCommand = new Command(...);
private static final Command rejectCommand = new Command(...);
private int limit;
private int counter;
private Alert confirmationAlert;
public void start() {
counter = 0;
limit = ...;
confirmationAlert = new Alert(...);
confirmationAlert.addCommand(acceptCommand);
confirmationAlert.addCommand(rejectCommand);
confirmationAlert.setCommandListener(this);
display.setCurrent(confirmationAlert);
}
public void commandAction(Command c, Displayable d) {
if (c == acceptCommand) {
doConfirmedAction();
}
counter++;
if (counter < limit) {
display.setCurrent(confirmationAlert);
} else {
display.setCurrent(nextScreen);
}
}
Graham.