#!/bin/sh # # This is a shell archive. To extract its contents, # execute this file with /bin/sh to create the file(s): # # README barcode25.4gl # # This shell archive created: Tue Jul 18 07:13:27 CDT 2000 # echo "Extracting file README" sed -e 's/^X//' <<\SHAR_EOF > README XFrom: Fernando_Ortiz_Mu=F1oz XTo: XSubject: Barcode on Laser printer Code I2of5 XDate: Fri, 14 Jul 2000 16:44:17 -0500 X XHi! X XI downloaded the great bc.4gl from Ti Lian Hwang for printing 3 of 9 Xbarcodes, and I coverted it to code Interleaded 2 of 5 for PCL printers Xonly. X XIt is anexed as a contribution to the community, I hope it'll by of use. X X XFernando Ortiz Mu=F1oz XFabrica de Jabon la Corona XDepartamento de Informatica SHAR_EOF if [ `wc -c < README` -ne 473 ] then echo "Lengths do not match -- Bad Copy of README" fi echo "Extracting file barcode25.4gl" sed -e 's/^X//' <<\SHAR_EOF > barcode25.4gl X# X# Filename: barcode25.4gl X# Desc : Barcodes on Laser Printers X# Date : 15 Jul 2000 X# Author : Adecuaciones de Fernando Ortiz X# del programa original para barras 3 de 9 de X# Ti Lian Hwang (tilh@sin-co.sg.dhl.com) X# X# FUNCTION lj_barcode_25(xpos,ypos,str,x,y) X# draws barcode at (xpos,ypos) with values of str X# of size x,y (all units in inches from bottom-right) X# X# The following code produces CODE I25 barcodes on an PCL. There are X# several different barcode standards, but these days most barcode readers X# will read all the major ones. X# X# I modified the original program of Ti Lian to make a string of all the X# escape sequences to build the barcode. That was much easier for me X# to use in the report. X# X# PAGE HEADER X# PRINT g_esc, "&a0r0C" # Go to very top of the page X# PRINT .... X# X# .... X# X# PAGE TRAILER X# LET w_refe = m_fech USING "ddmmyyyy", r.viaj USING "&&&&" # or whatever X# LET w_barra = lj_barcode_25(4.3, 0.9, w_refe, 3.5, 0.8) X# PRINT w_barra CLIPPED, ascii(12) # Form feed X# X XDEFINE atx,aty SMALLINT XDEFINE ysize SMALLINT XDEFINE littlebar SMALLINT XDEFINE bigbar SMALLINT X XDEFINE even_odd SMALLINT X XDEFINE ytotal SMALLFLOAT # length of paper XDEFINE x_inch,y_inch SMALLFLOAT XDEFINE line CHAR(256) XDEFINE fmt CHAR(12) XDEFINE vmi SMALLFLOAT X X# barcode variables XDEFINE x0,y0 SMALLFLOAT # top-left corner in decipoints XDEFINE width,height SMALLFLOAT # barcode size in decipoints XDEFINE fontsize SMALLFLOAT # size of font in points XDEFINE xscale SMALLFLOAT # scaling of barcode units to decipoints X X############################################################################ XFUNCTION lj_barcode_25(xpos,ypos,str,x,y) X############################################################################ XDEFINE str CHAR(64) XDEFINE xpos,ypos,bar_length,x,y SMALLFLOAT XDEFINE i SMALLINT XDEFINE largo_car SMALLINT XDEFINE font_size SMALLFLOAT XDEFINE bar_scale SMALLFLOAT XDEFINE w_rollo CHAR(4096) X XLET vmi = 12 # points XLET ytotal = 11.00 * 720 # inches by points per inch XLET x_inch = 0 XLET y_inch = 0 XLET fmt = "<<<<<<<.<<<<" X XLET littlebar=8 # these numbers are arbitrary, as long as the ratio XLET bigbar=20 # stays between 2:1 and 3:1 X X LET ysize = y * 72.0 # inch to points X LET font_size = y * 14.4 # 2/10 of height of bar X LET aty = y * 14.4 # 2/10 of height of bar X LET atx = 0 X LET largo_car = 2 * bigbar + 3 * littlebar X X LET i = LENGTH (str) X LET bar_length = largo_car * i + 6 * littlebar + X 1 * bigbar # delimiter X X LET bar_scale = (72.0 * x) / bar_length X LET w_rollo = "" X LET w_rollo = w_rollo CLIPPED, X lj_InitBar_25(xpos,ypos,x,y,font_size,bar_scale) X LET w_rollo = w_rollo CLIPPED, lj_PrintThis_25(UPSHIFT(str)) X RETURN w_rollo CLIPPED XEND FUNCTION X X# X# given an asciiz string, do what's necessary. tack on delimiter '*'s X# XFUNCTION lj_PrintThis_25(str) X X DEFINE str CHAR(64), X w_rollo CHAR(4096) X DEFINE x SMALLINT X X LET even_odd = TRUE # start in black X LET w_rollo = lj_PutBars_25('(') # starting delimiter */ X FOR x=1 TO LENGTH(str) STEP 2 X X LET w_rollo = w_rollo CLIPPED, lj_PutBars_25(str[x,x + 1]) X # do each double-char */ X X END FOR X LET w_rollo = w_rollo CLIPPED, lj_PutBars_25(')') # ending delimiter */ X RETURN w_rollo CLIPPED XEND FUNCTION X X# X# determine the actual thick/thin pattern for the submitted character X# XFUNCTION lj_PutBars_25(c) X DEFINE c CHAR(2), X t1, t2 CHAR(5), X t CHAR(10), X w_rollo CHAR(256) X XCASE (c) X WHEN '(' X LET w_rollo = lj_BarChar_25("0000") X WHEN ')' X LET w_rollo = lj_BarChar_25("100") X OTHERWISE X LET t1 = lj_checa_char_25(c[1,1]) X LET t2 = lj_checa_char_25(c[2,2]) X LET t = t1[1,1], t2[1,1], X t1[2,2], t2[2,2], X t1[3,3], t2[3,3], X t1[4,4], t2[4,4], X t1[5,5], t2[5,5] X LET w_rollo = lj_BarChar_25(t) XEND CASE XRETURN w_rollo CLIPPED XEND FUNCTION X XFUNCTION lj_checa_char_25(c) XDEFINE c CHAR, X t CHAR(5) X XCASE (c) X WHEN '1' LET t = "10001" X WHEN '2' LET t = "01001" X WHEN '3' LET t = "11000" X WHEN '4' LET t = "00101" X WHEN '5' LET t = "10100" X WHEN '6' LET t = "01100" X WHEN '7' LET t = "00011" X WHEN '8' LET t = "10010" X WHEN '9' LET t = "01010" X WHEN '0' LET t = "00110" XEND CASE XRETURN t XEND FUNCTION X X# X# given the thick/thin map of 9 0's and 1's, order up some rectangles X# of the appropriate sizes and positions X# XFUNCTION lj_BarChar_25(mapstring) X DEFINE mapstring CHAR(10) X DEFINE x,barsize SMALLINT X DEFINE w_rollo CHAR(512) X X LET w_rollo = "" X FOR x=1 TO length(mapstring) X IF (mapstring[x,x]=='0') THEN X # thin one */ X LET barsize=littlebar X ELSE X # thick one */ X LET barsize=bigbar X END IF X IF even_odd THEN X # black bar - draw it X LET even_odd = FALSE X LET w_rollo = w_rollo CLIPPED, X lj_DoRectangle_25(atx,barsize,aty ,ysize) X ELSE X # gap - do nothing X LET even_odd = TRUE X END IF X LET atx = atx + barsize # move over that much X END FOR X RETURN w_rollo XEND FUNCTION X X###################################################################### XFUNCTION lj_InitBar_25 (xpos,ypos,x,y,font_size,barscale) X###################################################################### XDEFINE xpos,ypos SMALLFLOAT # in inches, 0,0 is bottom-left XDEFINE x,y SMALLFLOAT # in inches, size of bar XDEFINE font_size SMALLFLOAT # in points XDEFINE barscale SMALLFLOAT # scaling of barcode units to points X XLET width = x * 720 XLET height = y * 720 XLET x0 = xpos * 720 XLET y0 = ytotal - (ypos * 720) - height XLET fontsize = font_size XLET xscale = barscale * 10 X X# attempt 300 dpi if no 600 dpi XLET line = ASCII(27),"*t300R", ASCII(27),"*t600R" XRETURN line CLIPPED XEND FUNCTION X X# X# low-level hp commands to fill rectangles X# X###################################################################### XFUNCTION lj_DoRectangle_25(atx,xsize,aty,ysize) X###################################################################### XDEFINE atx,xsize,aty,ysize SMALLINT XDEFINE xabs,yabs SMALLFLOAT X XLET xabs = x0 + (atx * xscale) XLET yabs = y0 XLET line = ASCII(27),"&a", xabs USING fmt, "h", yabs USING fmt, "V" # position X XLET xabs = xsize * xscale XLET yabs = height XLET line = line CLIPPED, X ASCII(27),"*c", xabs USING fmt, "h", yabs USING fmt, "V" # size XLET line = line CLIPPED, ASCII(27),"*c0P" # fill X XRETURN line CLIPPED X XEND FUNCTION SHAR_EOF if [ `wc -c < barcode25.4gl` -ne 6665 ] then echo "Lengths do not match -- Bad Copy of barcode25.4gl" fi echo "Done." exit 0