I am building an array of Tk button and each button will invoke the
same subroutine. However I need the index of the calling button to
be sent to the subroutine. So far I have a for loop and a SWITCH that
that works but it seems to me to be pretty poor coding:

  for ($intIndex=0; $intIndex<20; $intIndex++) {
    SWITCH: {
      if ($intIndex==0) { 
$objButton=$objFrame->Button(-background=>$BG,-borderwidth=>'1',-command=>sub 
{&FileBrowse($objWindow,"0")},height=>'1',-text=>'Browse')->pack(-side=>'top',-anchor=>'w');
 last SWITCH; }
            --------------------
            --- 1 to 18 here ---
            --------------------
      if ($intIndex==19) { 
$objButton=$objFrame->Button(-background=>$BG,-borderwidth=>'1',-command=>sub 
{&FileBrowse($objWindow,"19")},height=>'1',-text=>'Browse')->pack(-side=>'top',-anchor=>'w');
 last SWITCH; }
    }
    push @arrButton, $objButton;

As you can see the only thing that is changing is the constant "1" to "19"
in the subroutine parameters. I can't just use $intIndex as that is local
to this subroutine. Anyone see a simple concise way round this? TIA:)
-- 
-Timothy

eMail: [EMAIL PROTECTED]
WebPage: http://mail.asl.bc.ca/~timothy
(c) 883 GUE The FrobozzCo

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to