Clovertech
› Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › MOD10 TCL PROC?
Does anyone have a MOD10 tcl that they would like to share? I need to add the check digit back to the doctor before it enters the hospital system…
Thanks in advance! Mary
Here is a snippet of code that should work:
proc checkdigit { no } {
set pos [string length $no]
set t “”
foreach i [split $no “”] {
incr pos -1
append t [expr $i * (2 – $pos % 2)]
}
set result [expr (10 – [cross_sum $t] % 10) % 10]
proc cross_sum { s } { expr [join [split $s “”] “+”] }
HTH!