I think my mailer messed up, as those typos were not there. I can assure you, with the modifications I made, it works fine. Here's a complete version of the EasyWindow module with my modifications: package Mac::EasyWindow; use Mac::Windows; use Mac::Events; use Mac::QuickDraw; use Mac::Fonts; use strict; BEGIN { use Exporter; use vars qw(@ISA @EXPORT); @ISA = qw(Exporter); @EXPORT = qw(&DRAWING &WINDOW &SHOW &DESTROY); } my %vars = (); my $draw = ''; my $win = ''; sub DRAWING { my ($str) = @_; $draw = eval "sub { $str }"; } sub WINDOW { my($data ) = @_; my $height = defined $data->{height} ? $data->{height} : 200; my $width = defined $data->{width} ? $data->{width} : 200; my $x_pos = 16; my $y_pos = 52; my $title = 'EasyWindow'; my $bnd = new Rect($x_pos, $y_pos, $width+$x_pos, $height+$y_pos); $win = new MacColorWindow $bnd, $title, 1, 4, 1; $win->sethook('drawgrowicon', sub {1} ); $win->sethook('redraw', sub { &{ $draw } }); $win->window; } sub SHOW { WaitNextEvent while $win->window } sub DESTROY {$win->dispose if defined $win} 1; Here's what my previous message said according to my mailer: Hi- I modified my copy of EasyWindow as Kevin Reid suggested. Here is what I did: In the subroutine DRAWING, change $draw = $str; into $draw = eval "sub $str }"; In the subroutine WINDOW, where the redraw hook is defined, change val( $draw ) into &{ $draw } --Quentin ----- Original Message ----- From: "Alan Fry" <ajf@afco.demon.co.uk> To: "MacPerl Toolbox" <macperl-toolbox@macperl.org> Sent: Tuesday, June 27, 2000 5:28 PM Subject: Re: [MacPerl-Toolbox] QuickDraw and MacWindows > At 9:47 am -0400 27/06/00, Quentin Smith wrote: > > >In the subroutine DRAWING, change $draw = $str; into $draw = eval "sub > > $str }"; > >In the subroutine WINDOW, where the redraw hook is defined, change > >val( $draw ) into &{ $draw } > > That certainly doesn't work as set out, even with the obvious typos put right. > > A slight modification does work however: > > eval "sub draw {$str}"; # in EasyWindow::DRAWING > $win->sethook('redraw', \&draw); # in EasyWindow::WINDOW > > I am lost for a test to demonstrate how much of an improvement it > might be over the original. Presumably (?) the eval() is not now > called in an 'update' event, but how important is that anyway? Anyone > know? > > At 11:34 am -0400 27/06/00, Kevin Reid wrote: > > >sub DRAWING (&) { > > my ($sub) = @_; > > &$sub; # or save it for later > >} > > This retrieves '$sub' as a CODE reference to the block of QuickDraw > text -- yes? On the face of it, it looks likely the reference could > be used directly in the 'redraw' hook. However I have quite failed to > find a way to make that work. I suspect '&$sub' behaves as the > original text string, not a functioning sub-routine. At any rate > "print &$sub" merely returns the original, unadorned text string. > > Alan Fry > > ==== Want to unsubscribe from this list? > ==== Send mail with body "unsubscribe" to macperl-toolbox-request@macperl.org > ==== Want to unsubscribe from this list? ==== Send mail with body "unsubscribe" to macperl-toolbox-request@macperl.org