Can you catch the 'die' by putting the offending call in an eval block
(perldoc -f eval).
Regards,
Rob.
#!perl
use strict;
use warnings;
use Win32::GUI;
my $mw = Win32::GUI::Window->new(
-title => "Cheating death",
-pos => [100,100],
-size => [100,100],
);
$mw->AddButton(
-text => "Click me!",
-name => "B1",
);
$mw->Show();
Win32::GUI::Dialog();
exit(0);
sub B1_Click
{
eval {
die "'Don't press the button'";
};
warn "Warning: $@" if $@;
return 1;
}
__END__
Robinson wrote:
[docs]
Finally, you should note that events are really evaluated (as if they were
called with eval()), so that errors are trapped, and a message box is shown.
This box reports the offending event name on the title bar, the error
message in its body and has OK and Cancel buttons. If you press OK,
Win32::GUI will ignore the error and go on with the dialog (the event, of
course, doesn't take place); if you press Cancel instead the dialog will end
(with return code -1). This means that for example if you define an event
like:
sub Button1_Click {
die();
}
your script will not die immediately at the click of a button, but the
message box will appear, reporting for example ``Died at script.pl line
73''.
[/docs]
I'm using XMLRPC::Lite with Win32::GUI and if the person's offline, they'll
of course get an error which (in X::L) results in a call to die(). which
brings up the "OK/Cancel" box. which kills the app on cancel. Not what I'd
like to happen. Anyone know a way _around_ this?
--
Robinson
[EMAIL PROTECTED]
-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games. How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users