Created
January 31, 2012 15:46
-
-
Save ausuwardi/1711170 to your computer and use it in GitHub Desktop.
Print bar code with ESCP printers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* | |
* TestBC.prg | |
* | |
* Test printing barcode | |
* | |
#DEFINE BCT_EAN13 0 | |
#DEFINE BCT_EAN8 1 | |
#DEFINE BCT_INT25 2 | |
#DEFINE BCT_UPCA 3 | |
#DEFINE BCT_UPCE 4 | |
#DEFINE BCT_CDE39 5 | |
#DEFINE BCT_CDE128 6 | |
set talk off | |
set print on | |
do bcprint with BCT_CDE39, '1234567890' | |
set print off | |
return | |
procedure bcprint | |
parameters bctype, bcdata | |
private nh, nl, k, m, s, v1, v2, c | |
* total length = 6 + barcode data bytes | |
* where 6 bytes are k, m, s, v1, v2, and c | |
* see ESCP programming guide for command | |
* ESC ( B | |
store 0 to nh, nl | |
do split16 with 6+len(bcdata), nh, nl | |
k = bctype && barcode type | |
m = 2 && module width | |
s = 0 && spacing adjustmet | |
v1 = 21 && bar length | |
v2 = 0 && v1 + (v2 * 256) = 21/72 inch = 1/3 inch | |
c = 0 && flags | |
??? chr(27) + '(B' + chr(nl) + chr(nh) + chr(k) | |
??? chr(m) + chr(s) + chr(v1) + chr(v2) + chr(c) | |
??? bcdata | |
return | |
procedure split16 | |
parameters word, byteH, byteL | |
byteH = int(word / 256) | |
byteL = word % 256 | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment