[bmx] Calculate UPC-A Check Digit by daaan [ 1+ years ago ]

Started by BlitzBot, June 29, 2017, 00:28:38

Previous topic - Next topic

BlitzBot

Title : Calculate UPC-A Check Digit
Author : daaan
Posted : 1+ years ago

Description : I had to do this for work and thought I'd share.

Code :
Code (blitzmax) Select
Function CalcCheckDigit_UPCA:String(UPC:String="")

Local CheckDigit:Int = 0

For i:Int = 0 Until UPC.Length

CheckDigit :+ (Chr(UPC[i]).ToInt() * (1 + 2 * (i Mod 2)))

Next

Return (UPC+(10-(CheckDigit Mod 10)))

End Function


Comments : none...