You might want to check out the format command.
hcitcl>set x “123456”
hcitcl>set x1 ” 3456″
hcitcl>set x2 “3456”
hcitcl>set y [format “%06d” $x]
hcitcl>echo $y
123456
hcitcl>set y [format “%06d” $x1]
hcitcl>echo $y
003456
hcitcl>set y [format “%06d” $x2]
hcitcl>echo $y
003456