Add hupdateif <path> <value> [<format>] for conditional update of hipadaba

This commit is contained in:
Douglas Clowes
2014-08-19 13:57:46 +10:00
parent a93819572a
commit 2cb70741b1

View File

@ -917,6 +917,27 @@ proc handle_exception {status message args} {
}
}
proc hupdateif {path new_value {cmp_format ""}} {
if { ${cmp_format} == "" } {
if { [hpropexists ${path} compare_format] } {
set compare_format [hgetpropval ${path} compare_format]
} else {
set compare_format ""
}
} else {
set compare_format ${cmp_format}
}
if { ${compare_format} == "" } {
if { [hval ${path}] != ${new_value} } {
hupdate ${path} ${new_value}
}
} else {
if { [format ${compare_format} [hval ${path}]] != [format ${compare_format} ${new_value}] } {
hupdate ${path} ${new_value}
}
}
}
namespace import ::utility::*;
Publish getinfo spy
Publish setpos user