我今天在配置文件中遇到以下程序.......它是一個用偉大的智慧編寫的好程序....但是我沒有能力運行它.......如何執行程序,並可以將宏包含在tcl腳本中
proc parseFileContents {contents infoVar} {
upvar 1 $infoVar inf
set lineNum 0
foreach line [split $contents "\n"] {
incr lineNum # Skip comment lines (?)
if {[string match {$*} $line} continue # Skip blank lines
if {[string trim $line] eq ""} continue # Parse a "real" line
if {[scan $line "%s%s%s%s%s%s%f%f%s%s" a b c name d e value f g h] == 10} {
set inf($name) $value
} else {
# Oh dear, didn't work!
puts "warning: did not understand line $lineNum\n$line"
}
}
}
使用它:
parseFileContents $theContentsOfTheFile data
puts "Keys: [array names data]"
puts "VSS: $data(vss)" puts "VCC: $data(vcc)"
「我無法運行它」是什麼意思?有沒有錯誤信息? '$ theContentsOfTheFile'的內容是什麼? – bmk 2011-04-05 09:36:22
我發現很難執行它 – Naaz 2011-04-11 05:35:27