Open a file, and then readin a file tcl tk

 if { [catch {open $filn r }  f ] } {
    Report 3 "Could not open initialisation file $filn"
    return 0
  }

  set textin [split [ read $f ] "\n"]
  CloseFile $f
  set full_text ""
  foreach line $textin {
    if { [string range $line end end] == "\\" } {
      append buffer [string range $line 0 [expr {[string length $line] -2}]]
    } else {
      append buffer $line
      lappend full_text $buffer
      set buffer ""
    }
  }

posted @ 2011-04-15 22:42  greencolor  阅读(142)  评论(0编辑  收藏  举报