0

Hi I am trying the following code but I am getting an error. Its a precedure where I give a reference value and the procedure should move up or down the list. The code is:

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"
        }
    }
}

I am getting an error saying : Error: wrong # args: extra words after "else" clause in "if" command Use error_info for more info. (CMD-013) I dont know what is wrong with the for loop. Can someone please help me with this.

4

1 回答 1

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"
    }
}
于 2013-07-26T03:28:22.120 回答