Reply To: MOD10 TCL PROC?

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf MOD10 TCL PROC? Reply To: MOD10 TCL PROC?

#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!