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

write variables in a created file???

Status
Not open for further replies.

Sascha9876

Programmer
Oct 12, 2004
1
DE
I have a big problem:
I write a programm in TCL/TK and for this I need to write some data into a created file. My problem is that only string is written into the file!
My sample part of the program is:

#------------------------------------------------
proc makefile {}

global IK
set file [tk_getSaveFile]

puts $file
if {file != ""}
.gfenster.grafik
addtag "canvas_save_ignore" withtag "marker"

set selected [.gfenster.grafik find withtag "selected"

.gfenster.grafik dtag selected
}
set fid [open $file w+.open]
puts $fid {structure}
puts $fid {Node $IK}

close $fid

#--------------------------------------

Here is the problem I have: In the output is written:

structure
Node $IK

and I want that the value for IK is put in there... I don't have any idea how to cope with this problem and I would be very thankful if someone could help me!!!

Thanks a lot,

Sascha
 
The problem is the curly braces "{}". They delay substitution 1 step which you don't want. Try "puts $fid "Node $IK".
Also, there's an error in your "if" statement that I assume is just a typo: "if {file != ""}" should be "if {$file != ""}".

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

Part and Inventory Search

Sponsor

Back
Top