Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variables within frame names

Status
Not open for further replies.

rubberscissors

Technical User
Oct 11, 2001
21
US
Using Tk, I've created a series of buttons for a series of slots, and I've grouped the buttons into groups of 2. These buttons are packaged in frames as in the example below:

frame .slot1and2
button .slot1and2.slot1board1

Later, I call up a proceedure to cycle through different board types, and I pass values indicating slot group and slot depending on the button being clicked and I want to assign variables to the numbers in the frame/button names:

proc cycle { s1 s2 s3 } {

pack forget .slot$s1and$s2.slot$s3board1

}

The example above obviously doesn't work, but I've tried:

pack forget .slot{$s1}and{$s2}.slot{$s3}board1

and

pack forget .slot$s1\and$s2\.slot$s3\board1

The example with the slashes seems to come closest to working, but I get an error complaining that the path:

.slot1|nd2.slot1board1

is a bad path - the 'a' in 'and' gets converted to a garbage character...I changed the 'a' to another letter, thinking \a may be a special character...I changed it to 'f' but it still gives me an error. Does anyone know the correct syntax?
 
I figured it out...\f is a special character as well. I changed it to something different and it seems OK now.
 
I tried that which worked fine:

pack [frame .slot1and2]
pack [button .slot1and2.slot1board1 -text .slot1and2.slot1board1]

proc cycle { s1 s2 s3 } {
pack forget .slot${s1}and${s2}.slot${s3}board1
}

update
after 2000
cycle 1 2 1

ulis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top