proc ElementExists { arrayname element } {
#-----------------------------------------------------
# Test if a given element name exists in an array
# Return 1 if array element exists, otherwise return 0 \
# arrayname Name of array
# element Name of element
# if { ![array exists $arrayname] } { return 0 }
upvar #0 $arrayname array
if { [array names array $element] == $element } {
return 1
} else {
return 0
}
}