06160017.txt 16-Jun-00


Subject: Re: Barcode
From: joelfroese@my-deja.com

Don't let any scare you; writing creating barcodes entirely
in Clipper is not that hard. I've written procedures that
print 3 of 9 and postnet barcodes on HP LaserJet printers
and even on an old Epson dot-matrix!
Static Procedure CODE25LASR (Barcode)
  //code25lasr - prints USPS parcel barcode for given
  //  5-digit zip in Interleave 2 of 5 format to any HP
  //  LaserJet printer.
  STATIC Pattern :={"00110","10001","01001",;
    "11000","00101","10100","01100","00011",;
    "10010","01010"}
  // narrow bar - 15 x 550 decipoints
  STATIC NB := ".*c15h550v0P.&a+15H"
  // wide bar - 30 x 550 decipoints
  STATIC WB := ".*c30h550v0P.&a+30H"
  // narrow space - advance 15 decipoints
  STATIC NS := ".&a+15H"
  // wide space - advance 30 decipoints
  STATIC WS := ".&a+30H"
  // two narrow bars = starting frame bars
  LOCAL BARS := "00"
  LOCAL SPACES := "00" // two narrow spaces = "
  LOCAL X := 0 // pattern loop
  LOCAL V := 0 // printing loop
  LOCAL DIGIT := 0 // one digit of "Barcode"
  Barcode := alltrim(Barcode)+"9"
  if len(Barcode) # 6 .or. !isdigit(Barcode)
return
  endif
  FOR X = 1 TO 6 STEP 2   // encode "Barcode"
    DIGIT = val(substr(Barcode,X,1))
    Bars += Pattern[Digit+1]
    DIGIT = val(SUBSTR(Barcode,X+1,1))
    Spaces += Pattern[Digit+1]
  NEXT X
  Bars += "10"    // add end framing bars
  Spaces += "00"
  For V = 1 to Len(Bars)  // print the barcode
    if substr(Bars,V,1) = "1"
      ?? WB
    else
      ?? NB
    endif
    if substr(Spaces,V,1) = "1"
      ?? WS
    else
      ?? NS
    endif
  Next V
RETURN 