while (1) { if ($Quit) { $MW->destroy; last; } DoOneEvent($Running ? Tk::DONT_WAIT : Tk::ALL_EVENTS); iterate() if ($Running); save_is_active( 1 ) if (!$Running && !$SaveButtonActive); }