zoukankan      html  css  js  c++  java
  • Report write to logfile Tcl tk

    proc Report { text args }
    {
      set logfile [GetSystemVar SESSION_LOG]
      if { $logfile != "" } {
        WriteFile $logfile  "$text"
      }
    }


    proc WriteFile { filename text args } {
      set file_mode "a+"
      for { set i 0 } { $i < [llength $args] } { incr i } {
        set arg [lindex $args $i]
        switch -regexp -- $arg {
          overwrite {
            set file_mode "w"
          }
        }
      }
      if { ![OpenFile $filename fo $file_mode] } { return 0 }
      if {[catch {puts $fo "$text"}]} { return 0 }
      return [CloseFile $fo]
    }


    proc OpenFile { filename channel {mode a+ } } {
      upvar $channel f
      if {[file isdirectory $filename]} { return 0 }
      return [expr {1 - [catch { open $filename $mode } f ]} ]
    }


    proc CloseFile { f {filename ""} } {
      if { [catch "close $f" ] } {
        WarningMessage "Error closing file $filename
    Probably due to disk being full or exceeding disk quota"
        return 0
      } else {
        return 1
      }
    }

  • 相关阅读:
    不定方程(Exgcd)
    [模板]乘法逆元
    STL-Deque(双端队列)与单调队列的实现
    最优得分 score
    摆书 book
    [模板]树链剖分
    [模板]Splay
    NOIP2013 货车运输
    Java的类类型和类的动态加载
    Java:搜索特定后缀名的文件
  • 原文地址:https://www.cnblogs.com/greencolor/p/2016610.html
Copyright © 2011-2022 走看看