Using foreach loop to create radiobutton menu
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

Using foreach loop to create radiobutton menu

From: <aj@bookac.com>
Date: Fri Apr 28 2006 - 15:54:06 CEST

As it stands now, I have code that looks somethign like this....

menubutton range -text "Set Range" -underline 0 -bd 0 -menu {
   radiobutton range1 -label "1" -command {
     # do something...
   }
   .
   .
   .
   radiobutton range10 -label "10" -command {
     # do something...
   }
 }

I am trying to do the same thing in a foreach loop. I keep getting an
error though saying variable range does not exists: Here is that
code...

menubutton range -text "Set Range" -underline 0 -bd 0 -menu {
     foreach range {1 2 3 4 5 6 7 8 9 10} {
         radiobutton range$range -label $range -command {
          puts "hello: $range"
       }
    }
}

I understand that range is out of scope. Can anyone tell me how to
make it so it is in scope? I tried using upvar and uplevel to no
avail.
Received on Sun Apr 30 03:30:34 2006