diff --git a/site_ansto/instrument/util/extra_utility.tcl b/site_ansto/instrument/util/extra_utility.tcl index 88ffbab5..ba8da11f 100644 --- a/site_ansto/instrument/util/extra_utility.tcl +++ b/site_ansto/instrument/util/extra_utility.tcl @@ -236,3 +236,13 @@ proc error_msg {args} { set arglist [lrange $cmdinfo 1 end] error "ERROR: [namespace origin $cmd] $arglist: $args" } + +# Use this function if you expect a decimal number which might be +# padded with zeroes. +# \brief Strips leading zeroes from decimal numbers. +# NOTE: It's up to you to check if the unpadded string is a valid number. +# +# Handles 0 and numbers prefixed with - or +. +proc unpad {n} { + return [regsub {([+-])?0*(\d+)} $n {\1\2}] +}