* run pre code * create modeless top form * set a wait callback event for topForm unload * bindevent(topForm,"UnLoad",m.thisForm,"CallBack",1) * don't forget to add a character to the topForm's Unload method * put the rest of the code int othe thisform.CalbackOf course it demands that not there are scope ties.