ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-tk
perl-tk
Re: configuring a 'repeat' callback
by Ala Qumsieh other posts by this author
Oct 30 2002 8:00PM messages near this date
Re: configuring a 'repeat' callback | Re: configuring a 'repeat' callback
On Wed, 30 Oct 2002, Steve Lidie wrote:

>  Well, here's possibly a better patch, and with doc changes too, against 
>  Tk804.024. The difference is now invoking
>  $id->time(0) cancels the timer event - just another way of saying 
>  $id->cancel.

Great idea. I would like to propose a couple of tiny changes though.

Your code:

sub time {
    my $obj = shift;
    my $delay = shift;
    if (defined $delay) {
       $obj-> cancel if $delay == 0;
       $obj-> [2] = $delay;
    } else {
       $obj-> [2];
    }
}

If it were up to me, I would change the code to this:

sub time {
    my $obj = shift;
    my $delay = shift;

    if (defined $delay) {
       if ($delay =~ /^\+?\d+$/) {
           $obj-> cancel if $delay == 0;
           $obj-> [2] = $delay;
       } else {
           carp "argument must be a non-negative integer";
       }
    }

    $obj-> [2];
}

Changes:

1) Make sure $delay is a a non-negative integer. If not, throw a warning.
2) Return the delay in all cases.

Just my two cents,
--Ala


-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu
Thread:
Slaven Rezic
Nick Ing-Simmons
Steve Lidie
Nick Ing-Simmons
Steve Lidie
Steve Lidie
Ala Qumsieh
Steve Lidie
Nick Ing-Simmons

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved