Re: Tkx catch and selection

[email protected] (Jeff Hobbs) Sun, 9 Dec 2012 16:47:56 -0800
Newsgroups perl.tcltk
Message-ID <[email protected]>
On 2012-12-06, at 7:59 PM, Ken Preslan <[email protected]> wrote:
> I solved this problem in Perl/Tk with catch:
> Tk::catch { $string = $g_w_main->SelectionGet(); };
> 
> I assume this is just a mapping to Tcl's catch.  So, I can do:
> $string = Tkx::catch('selection get');
> 
> However, this just sets $string to the result of catch, a number.  How do
> I get the results of the 'selection get' assigned to a Perl variable?

This needs testing, but you want the multi-arg version of catch to get the result.

my $string;
if (Tkx::catch('selection get', \$string)) {
   # error occurred
} else {
   # $string should have result
}

Jeff