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!

question about appending to files in tcl 1

Status
Not open for further replies.

smugindividual

Programmer
Apr 14, 2003
104
US
Using 8.3.

Is there a file append command hidden in the depths of tcl? It is such a pain to add one line of text to an already existing file. If you know of such a function or of a clever way of doing this, I'd be greatful. (other than reading file to a variable and writting to a new file with new line appended on end)


Thanks in advance
 
Have you looked at the documentation for the open command?
a or a+ is the mode that you want.

proc appendLine {fname line {mode "a"}} {

if {![catch {set fd [open $fname $mode]} err_open]} {
puts $fd $line
close $fd
return [file size $fname]
} else {
puts "ERROR: $err_open"
return -1
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top