您好我正在尝试以下代码,但我收到一个错误。它是一个precedure,我给出一个参考值,程序应该在列表上下移动。 代码是:
proc getvalue {reference direction} {
if {[regexp {(.*)(x.*$)} $reference cellname family string]} {
puts $family
puts $string
} else {
puts " No string matched"
}
set mylist [T_sel2list [get_lib_cells "*/*${family}*"] ]
set sorted_finallist [lsort $mylist]
set i [lsearch $sorted_finallist *$string ]
if {$direction == "DOWN"} {
if {$direction == "DOWN" && $i > 0} {
incr i -1
set requiredDOWN [lindex $sorted_finallist $i]
puts "$requiredDOWN"
} else {
puts "First in the line"
} else {$direction == "UP" && $i >= 0 && $i < [llength $sorted_finallist] -2} {
incr i
set requiredUP [lindex $sorted_finallist $i]
puts "$requiredUP"
} else {
puts "Last in the line"
}
}
}
我收到一条错误说: 错误:错误#args:“if”命令中“else”子句后的额外单词 使用error_info获取更多信息。 (CMD-013) 我不知道for循环有什么问题。有人可以帮我这个。
答案 0 :(得分:1)
这可能是你的意思吗?
if {$direction == "DOWN"} {
if {$direction == "DOWN" && $i > 0} {
incr i -1
set requiredDOWN [lindex $sorted_finallist $i]
puts "$requiredDOWN"
} else {
puts "First in the line"
}
} else {
if {$direction == "UP" && $i >= 0 && $i < [llength $sorted_finallist] - 2} {
incr i
set requiredUP [lindex $sorted_finallist $i]
puts "$requiredUP"
} else {
puts "Last in the line"
}
}