Reply To: MOD10 TCL PROC?

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

Forum Statistics

Registered Users
5,116
Forums
28
Topics
9,292
Replies
34,432
Topic Tags
286
Empty Topic Tags
10