in reply to Re: Help with TK writing shorter code
in thread Help with TK writing shorter code

Thanks for your help. Is there a way to identify which slot a given start button is associated with? Thanks.
  • Comment on Re^2: Help with TK writing shorter code

Replies are listed 'Best First'.
Re^3: Help with TK writing shorter code
by zentara (Cardinal) on Sep 22, 2011 at 17:50 UTC
    The button is defined by $x, in the sub make_slot
    $goSlot[$x] = $slot->Button()
    so keep track of $x.

    What are you trying to do with the button tracking?


    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
      I'm trying to figure out how to keep track of $x. I want to be able to pass a unique serial number that is associated with the start button. So, for example, if slot 1 contained serial number 01234567, I want to be able to process that serial number if slot 1's start button is pressed. I'm pretty new to perl so I'm kind of floundering here. Thanks for your help.

        You could pass the slot number to the compute call:

        $goSlot[$x] = $slot->Button( ... -command => sub { compute($x) },

        Then, in the compute sub, you can access @sernums, @partnums, etc. e.g.:

        sub compute { my( $slotnum ) = @_; print "sernum=$sernums[$slotnum], partnum=$partnums[$slotnum]\n"; }
        I reckon we are the only monastery ever to have a dungeon stuffed with 16,000 zombies.