why would you ever want to while loop to pause your code
just pass a function and get the function which handles the timer to call it when it is up and you can use closures to pass variables
eg
code:
var callback;
function myCode(arg1){
//do stuff
//oh noes now i need to sleep to wait for a value
//function to call when timer is up
function returnCallback(arg1){
function callback(arg){
return arg1 * arg;
}
return callback;
}
callback = returnCallback(5);
MsgPlus.AddTimer("MyTimer",5000);
}
function OnEvent_Timer(TimerId){
if(TimerId == "MyTimer"){
//it should show the result of 5*5
Debug.Trace(callback(5));
}
}
more on javascript closures here
http://jibbering.com/faq/faq_notes/closures.html