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

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

Replies are listed 'Best First'.
Re^4: Help with TK writing shorter code
by alexanderp98 (Novice) on Sep 22, 2011 at 18:17 UTC
    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.
        Thanks, jdporter.