in reply to slow code help
This function would be called like so:{ # these are only visible to the function my @settings = ( [ (0,0), "red", "E = 0" ], [ (1e-99, 1e-90), "orange", "1e-99 < E < 1e-90" ], ... ); sub color_and_msg { my ($boo, $tab, $balloon) = @_; my ($color, $msg) = ("black", ""); for (@settings) { my ($low, $high, $c, $m) = @$_; if ($low <= $boo and $boo < $high) { ($color, $msg) = ($c, $m); last; } } my $frame = $tab->Label( -bg => $color, -relief => 'sunken', -width => 10, ); $balloon->attach($frame, -balloonmsg => $msg) if $msg; return $frame; # if you need it } }
and it does all the work, in a far more compact fashion.my $frame = color_and_msg($boo, $tab, $balloon);
_____________________________________________________
Jeff[japhy]Pinyan:
Perl,
regex,
and perl
hacker, who'd like a job (NYC-area)
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
|
|---|