Homepage › Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › MOD10 TCL PROC? › Reply To: MOD10 TCL PROC?
March 17, 2005 at 7:35 pm
#56102
Steve Drozdowski
Participant
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!