1 year ago
#74703
Andrus
How to print barcodes containing letters
How to print codes
E27H, D18H, F28G, J16H, E19G, G29F, I19F, K09F, L18F
as barcodes from Visual FoxPro application. I tried code below with Code 128 font but barcodes for those codes are created incorrectly:
StrTo128B('D18H') appears as D18 in printer bar code
StrTo128B('F28G') appears as 228
StrTo128B('J16H') appears as J16
It looks like if StrTo128B() result contains chr(81) and some other characters, those will not appear in output file:
Other bar codes are printed correctly. Use font script is not chacked:
* Converts a string to be printed with
* True Type Font "PF Barcode 128"
* Numerics and alphabetic (upper and lower case)
* If a character is not valid it is replaced by a space
* USE: _StrTo128B('Codigo 128 B')
* RETURNS: Character
* http://www.portalfox.com/index.php?name=News&file=article&sid=2600
FUNCTION StrTo128B(tcString)
LOCAL lcStart, lcStop, lcRet, lcCheck, ;
lnLong, lnI, lnCheckSum, lnAsc
lcStart = CHR(104 + 32)
lcStop = CHR(106 + 32)
lnCheckSum = ASC(lcStart) - 32
lcRet = tcString
lnLong = LEN(lcRet)
FOR lnI = 1 TO lnLong
lnAsc = ASC(SUBS(lcRet,lnI,1)) - 32
IF NOT BETWEEN(lnAsc,0,99)
lcRet = STUFF(lcRet,lnI,1,CHR(32))
lnAsc = ASC(SUBS(lcRet,lnI,1)) - 32
ENDIF
lnCheckSum = lnCheckSum + (lnAsc * lnI)
ENDFOR
lcCheck = CHR(MOD(lnCheckSum,103) + 32)
lcRet = lcStart + lcRet + lcCheck + lcStop
*--- Esto es para cambiar los espacios y caracteres invalidos
lcRet = STRTRAN(lcRet,CHR(32),CHR(232))
lcRet = STRTRAN(lcRet,CHR(127),CHR(192))
lcRet = STRTRAN(lcRet,CHR(128),CHR(193))
RETURN lcRet
ENDFUNC
barcode
visual-foxpro
foxpro
barcode-printing
code128
0 Answers
Your Answer