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!

Hi,all image create photo image

Status
Not open for further replies.

waistcoat

Programmer
Aug 2, 2003
15
CN
Hi,all
image create photo image1a -file [file join $tk_library demos images Lb1.gif]
Above is part of my program.The first time I ran it in
the program.It works well.But when I saved it and open it
again,it can not work.
Error:cannot read "tk_library":no such variable.
Can anyone tell me where is wrong?
THANKS
 
I guess that the first time you evaled the line at a global level and the second time inside a proc.

tk_library is defined at the global level and its use needs:
- a global tk_library declaration inside the proc
- or the ::tk_library syntax.
Code:
  # case 1
  proc myproc1 {args}   {
    global tk_library
    ...
    image create photo image1a -file [file join $tk_library demos images Lb1.gif]
    ...
  }
  # case 2
  proc myproc2 {args}   {
    ...
    image create photo image1a -file [file join $::tk_library demos images Lb1.gif]
    ...
  }
My preference is for the :: syntax that is coherent with the namespace syntax.

HTH

ulis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top