diff --git a/site_ansto/instrument/util/write_tree.tcl b/site_ansto/instrument/util/write_tree.tcl index 989eb8d4..75382d53 100644 --- a/site_ansto/instrument/util/write_tree.tcl +++ b/site_ansto/instrument/util/write_tree.tcl @@ -1,35 +1,54 @@ namespace eval ::utility {} proc ::utility::writeNode {tc_root { do_props 0 } { level 0 }} { - set space [string repeat " " $level] - set val [hval $tc_root] - set nam [lindex [split $tc_root "/"] end] - if {"$val" == ""} { - set line "$nam ([hinfo $tc_root])" - } else { - set line "$nam ([hinfo $tc_root]) = $val" - } - clientput "$space* $line" - if {"[string tolower "$do_props"]" == "-prop"} { - set props [hlistprop $tc_root] - #clientput "<<$props>>" - foreach prop $props { - #clientput "prop: $prop" - set flds [split $prop "="] - #clientput "flds: $flds" - if {[llength $flds] > 1} { - set fld0 [lindex $flds 0] - #clientput "fld0: $fld0" - if {[hpropexists $tc_root $fld0]} { - set rst [hgetprop $tc_root $fld0] - set nam [lindex [split [lindex $rst 0] "."] 1] - set rst [join [lrange [split $rst " "] 1 end] " "] - clientput "$space - $nam $rst" + if [ catch { + set space [string repeat " " $level] + if [ catch { + set val [hval $tc_root] + } message ] { + clientput "Error in writeNode/hval for $tc_root : $message" + return + } + set nam [lindex [split $tc_root "/"] end] + if [ catch { + if {"$val" == ""} { + set line "$nam ([hinfo $tc_root])" + } else { + set line "$nam ([hinfo $tc_root]) = $val" + } + } message ] { + clientput "Error in writeNode/hinfo for $tc_root : $message" + return + } + clientput "$space* $line" + if {"[string tolower "$do_props"]" == "-prop"} { + if [ catch { + set props [hlistprop $tc_root] + } message ] { + clientput "Error in writeNode/hlistprop for $tc_root : $message" + return + } + #clientput "<<$props>>" + foreach prop $props { + #clientput "prop: $prop" + set flds [split $prop "="] + #clientput "flds: $flds" + if {[llength $flds] > 1} { + set fld0 [lindex $flds 0] + #clientput "fld0: $fld0" + if {[hpropexists $tc_root $fld0]} { + set rst [hgetprop $tc_root $fld0] + set nam [lindex [split [lindex $rst 0] "."] 1] + set rst [join [lrange [split $rst " "] 1 end] " "] + clientput "$space - $nam $rst" + } } } } - } - foreach node [hlist $tc_root] { - ::utility::writeNode $tc_root/$node "$do_props" [expr {$level + 1}] + foreach node [hlist $tc_root] { + ::utility::writeNode $tc_root/$node "$do_props" [expr {$level + 1}] + } + } message ] { + clientput "Error in writeNode for $tc_root : $message" } }