Discussion:
EAN13 printing
(too old to reply)
José Dequeker
2020-10-20 13:37:03 UTC
Permalink
Hi,
Anyone has code to create the last digit from an ean13 barcode.
And also the code to convert the barcode to be able to print it with a windows ean-13 font?

Greetings,
Jos Dequeker
Colin Reynolds
2020-10-21 08:23:26 UTC
Permalink
Post by José Dequeker
Hi,
Anyone has code to create the last digit from an ean13 barcode.
And also the code to convert the barcode to be able to print it with a windows ean-13 font?
Greetings,
Jos Dequeker
A Barcode is just a number and the last digit oof an EAN 13 code is a check digit. It sould be easy to retrieve the last (rightmost) digit from this number.
Try something like this.
xcode = int(barcode /10) !to strip out the last digit
ycode = barcode % (xcode*10) !the modulus operator should return the last digit of the barcode

There might be other (simpler, or even correct) solutions but I haven't had my coffee yet!

Printing should not be an issue. I guess that there must be a few barcode printing templates out there.
José Dequeker
2020-10-22 07:26:40 UTC
Permalink
The solution:
Barcode = CLIP(LEFT(BarcodeString)) !209089200350
L = 12

!*******************Controlegetal berekenen

Som# = 0
J# = 0
LOOP I# = L TO 1 BY -1
J# += 1
IF (J# % 2)
Co# = 3
ELSE
Co# = 1
END
Som# += (Barcode[I#] * Co#)
END
Digit = (10 - (Som# % 10)) %10
Chaine = CLIP(Barcode) & Digit !2090892003508


!*********************tekst voor afdruk barcode berekenen

first# = barcode[1]

loop i# = 3 To 7
tableA# = 0
Case i#
of 3
Case first#
of 0 orof 1 orof 2 orof 3
tableA# = True
End
of 4
Case first#
of 0 orof 4 orof 7 orof 8
tableA# = True
End
of 5
Case first#
of 0 orof 1 orof 4 orof 5 orof 9
tableA# = True
End
of 6
Case first#
of 0 orof 2 orof 5 orof 6 orof 7
tableA# = True
End
of 7
Case first#
of 0 orof 3 orof 6 orof 8 orof 9
tableA# = True
End
End
If tableA# Then
CodeBarre = CodeBarre & Chr(65 + chaine[i#])
Else
CodeBarre = CodeBarre & Chr(75 + chaine[i#])
End
.
CodeBarre = CodeBarre & '*' !Add middle separator
loop i# = 8 To 13
CodeBarre = CodeBarre & Chr(97 + chaine[i#])
.
CodeBarre = CodeBarre & '+' !Add end mark
return(CodeBarre)
Colin Reynolds
2020-10-22 09:24:01 UTC
Permalink
Barcode = CLIP(LEFT(BarcodeString)) !209089200350
L = 12
Ok, I get it now <G>
Your Barcode is extracted from a String and NOT a Long (Number), and you wanted to CREATE a checkdigit and ADD it to the end of your Barcode String.

You should have said so <G>

Also, why not make your Barcode and BarcodeString CSTRING's to do away with the "CLIP(LEFT())" stuff, then use the LEN(barcode) function to assign a value to the variable "L" ?
Loading...