⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 defaults.tcl

📁 MPICH是MPI的重要研究,提供了一系列的接口函数,为并行计算的实现提供了编程环境.
💻 TCL
字号:
## A system of simple default-picking for Upshot## Be sure to set the variable 'defaultFile' before using this package.# If it is not set, it will default to ~/.tcl_defaults## Ed Karrels# Argonne National Laboratory#if ![info exists package(defaults)] {set package(defaults) yupsource $progdir/common.tclproc GetDefault {index default} {   global defaults defaultFile   if ![info exists defaultFile] {      set defaultFile ~/.tcl_defaults   }   if ![info exists defaults($index)] {      if [file readable $defaultFile] {	 set fileHandle [open $defaultFile r]	 while {[gets $fileHandle str]>=0} {	    # skip blank lines	    if {[llength $str] == 0} continue	    #  skip comment lines	    if {[string index $str 0] == "#"} continue	    if {[llength $str] != 2} {	       puts stderr "Format error in $defaultFile"	       return $default	    }	    SplitList $str {readIndex readValue}	    set defaults($readIndex) $readValue	 }	 close $fileHandle      } else {	 # puts "Cannot read $defaultFile"	 return $default      }	      if [info exists defaults($index)] {	 return $defaults($index)      } else {	 return $default      }   } else {      return $defaults($index)   }}proc UpdateDefaults {{newValueList {}}} {      # use this function to update the list of defaults and write them      # out to the file   global defaults defaultFile   if ![info exists defaultFile] {      set defaultFile ~/.tcl_defaults   }   set numValues [expr [llength $newValueList]/2]   for {set i 0} {$i<$numValues} {incr i} {      set defaults([lindex $newValueList [expr $i*2]]) \	    [lindex $newValueList [expr $i*2+1]]   }      # if we have read rights to the file, read it   if [file readable $defaultFile] {      set fileHandle [open $defaultFile r]      while {[gets $fileHandle str]>=0} {	 # skip blank lines	 if {[llength $str] == 0} continue	 #  skip comment lines	 if {[string index $str 0] == "#"} continue	 SplitList $str {readIndex readValue}	 if ![info exists defaults($readIndex)] {	    set defaults($readIndex) $readValue	 }      }      close $fileHandle   }   if {[file exists $defaultFile] ? [file writable $defaultFile] : \	 [file writable [file dirname $defaultFile]]} {      set fileHandle [open $defaultFile w]      foreach idx [array names defaults] {	 puts $fileHandle [list $idx $defaults($idx)]      }      close $fileHandle   }}}# set package(defaults) yup

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -