PDA

View Full Version : Confirmation Message Box -- how to use it in an elegant way inside a function?



Juel
18 Nov 2010, 1:20 AM
Hi,

I'm trying to use a message box in an appropriate way inside a function. My problem is that I need
the resulting answer - whether user clicked yes or no inside that function.
Here is some pseudocode of what I intend to do:


function(){
// some calculations
answer = getAnswerAndShowYESNOMessageBox
var x;
if(answer=='yes'){
x = 1;
}else{
x = 2;
}
// finish calculations using x
}

I can easily display the box and get into the if(answer=='yes') block, but I have no ideo of how to return
the clicked state of the message box into a variable while staying in that function and waiting until user has clicked.
I could probably split my function into several parts which are called accordingly, but is there a more elegant way without splitting?

Thanks for your ideas,

JUEL