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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help needed to configure button!!!

Status
Not open for further replies.

sergelaurent

Technical User
May 30, 2005
52
0
0
FR
Hi, I got the following code

for {set i 0} {$i<20} {incr i} {
#Creation des différents buttons
set j [expr $i+2]
set "temp_nom" "c:\\Laurent\\sauvegarde\\$nom($i).*"
puts $"temp_nom"
button ".test.f.b$j" -text $nom($i) -command { \
exec {C:\Program Files\Microsoft Office\Office\WINWORD.EXE} $"temp_nom$i"
} -justify center
#Placement du button
pack configure ".test.f.b$j" -side top
}

I would like to create 20 different buttons. However, when clicking on each button, it always open the same file. I have concluded that since the command is executed only when I activate the button, it seems logical that I open on the the file attributed to button19.
So I wanted to know how I can male each button open a file or a few files when using a loop?

Thanks in advance,
lolo
 
I'm not sure but I think your problem is my old nemisis: Curly Braces. The "{}" braces delay substitution until execution; at that time $i=19. Instead of -command { \
exec {C:\Program Files\Microsoft Office\Office\WINWORD.EXE} $"temp_nom$i"}
try:
-command [red]"[/red]exec {C:\Program Files\Microsoft Office\Office\WINWORD.EXE} $temp_nom$i[red]"[/red]

_________________
Bob Rashkin
rrashkin@csc.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top