我今天在配置文件中遇到以下程序.......它是一个用伟大的智慧编写的好程序....但是我没有能力运行它.......如何执行程序,并可以将宏包含在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