Re: Bar code printing
Posted in 1998
Michael, Here is some code that I am using to print text/barcodes on a SATO label printer... It does not help you with the HP part, but it could be modified for your use! Steve [report.ifg] output top margin 0 bottom margin 0 left margin 0 right margin 80 page length 2 [satotext.ext] ###################################################################### start file "report.4gl" ###################################################################### # See satopntr.ext for details... before block report1 on_every_row_1 print doSATOln("0050 0000 0000A","beg/set base","") print doSATOln("0040 0170 6010T",rpt.desc1,rpt.desc2) print doSATOln("0040 0245 4030T","QTY:","1") print doSATOln("0040 0285 7030T","PART:",rpt.item_code) print doSATOln("0040 0360 7030T","LOT:","123456") print doSATOln("0050 0640 3030T","CAUTION:","Irritating Substance") print doSATOln("1111 0800 1001B","1000110001","") print doSATOln("0000 0000 0000Z","end label","") goto skipDefPrinting ; after block report1 on_every_row LABEL skipDefPrinting: ; [satopntr.ext] ###################################################################### start file "report.4gl" ###################################################################### after block EOF NUL ###################################################################### function doSATOln(posStr, prtStr, prtAdd) ###################################################################### # slc 08/18/98 # Add satotext and satopntr to base.set # Add your print commands to the satotext.ext file: # before block report1 on_every_row_1 # print doSATOln("0010 0000 0000A","","") # print doSATOln("0145 0300 3020T","Part #:","") # print doSATOln("0000 0340 0470U","","") # print doSATOln("0270 0280 2030T","30-1234","") # repeat for each item... # print doSATOln("0000 0000 0000Z","") # goto skipDefPrinting # semicolon # after block report1 on_every_row # LABEL skipDefPrinting: # semicolon # # Format your strings as "xxxx yyyy fpprt","string","str2" # Where: xxxx = x position (basepos in A) # yyyy = y position (basepos in A) # f = font (0=underline and string contains endpos) # pp = pitch # r = rotate barcode (0=normal 1=90 etc) # t = type (A=Begin T=text U=underline B=barcode Z=End Label) define posStr char(20), prtStr char(255), prtAdd char(255), ESC char(1), nLen integer let ESC = ascii 27 let nLen = 1 case(posStr[15,15]) when "A" # Beg let scratch = ESC, "A", ESC, "#E2", ESC, "CC1" let scratch = scratch clipped, ESC, "A3", "H", posStr[1,4], "V", posStr[6,9] exit case when "Z" # End let scratch = ESC, "Q1", ESC, "Z" exit case when "U" # Underline let scratch = "" if(posStr[1,4] != "0000") then let scratch = ESC, "H", posStr[1,4] end if let scratch = scratch clipped, ESC, "V", posStr[6,9], ESC, "FW02H", posStr[11,14] exit case when "B" # Barcode let scratch = ESC, "H", posStr[1,4], ESC, "V", posStr[6,9] if(posStr[14,14] != "0") then let scratch = scratch clipped, ESC, "%", posStr[14,14] end if let scratch = scratch clipped, ESC, "BG02070>I" let scratch = scratch clipped, prtStr[1,10], ESC if(posStr[14,14] != "0") then let scratch = scratch clipped, ESC, "%0" end if exit case when "T" # Text let prtStr = prtStr clipped, " ", prtAdd let nLen = length(prtStr) if nLen = 0 then let nLen = 1 end if let scratch = ESC, "H", posStr[1,4], # xxxx ESC, "V", posStr[6,9], # yyyy ESC, "BJR", posStr[11,11], # f "0101", posStr[12,13], # pp nLen using "&&&&&&", prtStr otherwise # Error let scratch = "Error: Unknown option" exit case end case return scratch clipped end function # doSATOln ; Michael Hoffman <mrh@panix2.panix.com> wrote in article <6ri57c$knh@news1.panix.com>... > Hi all, > This is not specifically a 4GL problem, but I'm hoping someone > can point me in the right direction. > > I have a 4GL report that needs barcodes printed on it (for labels). > The barcode number values are stored in a field in the DB. > > I am printing on an HP LaserJet 4si with both internal and Postscript > fonts. > > What are the escape codes (and how do I write them) that need to be > included in the report? I believe I just have to say "print escape_sequence" > and the printer will set itself accordingly. > > Oh, before you say RTFM, I'm a consultant here and they don't have the > FM!!! :-} I tried calling HP, but they are totally unresponsive. > > Have any of you done barcode printing before? Any help would be much > appreciated. (And if in the NYC area, worth a beer or two!) > > Thanks, > Michael Hoffman > > >