proc h2d {{hex_num 0}} {
return [format "%d" 0x$hex_num]
}
proc d2h {{dec_num 0} {width 1}} {
return [format "%0${width}x" $dec_num]
}
set dbg_switch close
proc dbg {{switch 0}} {
global dbg_switch
if {"$switch" == "open" || "$switch" == "close"} {set dbg_switch $switch }
return $dbg_switch
}
proc do {var str args } {
set cmds [set end ""]
set step [split $str :]
set begin [lindex $step 0]
set dt [lindex $step 1]
set end [lindex $step 2]
if {"$end" == ""} {
set end $dt; set dt [expr abs($dt)/$dt]
}
incr end $dt
foreach a $args {append cmds "$a "}
regsub -all "%${var}" $cmds \${i} cmds
global dbg_switch
for {set i $begin} {[expr abs($end-$i)] >= [expr abs($dt)]} {incr i $dt} {
if {"$dbg_switch" == "open"} { puts "$i-->$cmds" }
eval $cmds
}
}
do a 1:1:5 puts \"%a bc %a dfdfd\"