Reputation: 11
i want to print certain vdd and ground in waiver file(fh) which satisfy the condition and print in waiver file.
*set matrix_waiver($pwr_name,$gnd_name) 1
if { [info exists matrix_waiver] } {
foreach power $pwr_name {
if { [info exists matrix_waiver($power) ] } {
lappend matrix_waiver $fh_waiver
}
}
foreach ground $gnd_name {
if { [info exists matrix_waiver($ground) ] } {
lappend matrix_waiver $fh_waiver
}
}
}*
am not getting desired output..whats the error in above code?
Upvotes: 0
Views: 72
Reputation: 137627
Your problem is that you're using a variable (matrix_waiver
) as both a simple variable and an associative array. That's not going to work (well, not unless the variable is unset
between, which I don't think you want to do). The two are fundamentally different in Tcl (they're two of the major types of variable; the third one is a link, which is used to implement global
and upvar
and you can usually ignore that).
If the actual data (which you don't show us) is a simple variable, which still might include complex structures such as lists and dictionaries within it, then you're going to have to use lindex
and lset
and lappend
and so on to work with it.
If the actual data is an associative array, you'll need to supply the correct element names when doing lappend
and so on.
Upvotes: 1