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 ""
    }
  }

原文地址:https://www.cnblogs.com/greencolor/p/2017598.html