Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Zebra-label printer and epl2
Message
From
21/10/2003 12:49:47
 
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
00840567
Message ID:
00840725
Views:
19
Hi, Thomas-
>
>has anyone ever used a Zebra-label-printer for
>printing labels by using epl2 and could
>give me some advise or code-snippet how
>to do that?

You've probably already downloaded the EPL2 programming manual, but just in case you haven't (or for anyone else reading this), you can d/l from this page: http://www.zebra.com/SS/manuals.htm. Look under "programming manuals." You'll have to register on the site, but IIRC there wasn't any problem with getting the docs.

I've programmed for the TLP 2844. It (the printer) works really well for my client, and the programming was relatively simple. We use a custom label size, so the biggest headache was getting figuring out how to program the label size. You just create a text file then copy the text file to the printer.

Anyway, here's my code snippet for printing the label. I use a different technique than Fernando. There is a compile conditional IF that documents the printer codes I'm using.
DEFINE CLASS zebralabel AS rbproductlabel


  NAME = "zebralabel"


  PROCEDURE itemprice_assign
    LPARAMETERS vNewVal
    *!* 04/05/03 13:35:26 nf 2: Changed from IF to CASE.
    *!* Sometimes the price is being cut off in the Received PO form
    DO CASE
    CASE VARTYPE(vNewVal)="Y"
      THIS.ItemPrice = ALLTRIM(TRANSFORM(MTON(vNewVal),"@$"))
    CASE VARTYPE(vNewVal)="N"
      THIS.ItemPrice = ALLTRIM(TRANSFORM(vNewVal,"@$"))
    CASE VARTYPE(vNewVal) = "C"
      THIS.ItemPrice = ALLTRIM(vNewVal)
    OTHERWISE
      THIS.ItemPrice = ""
    ENDCASE
  ENDPROC


  PROCEDURE PRINT
    LPARAMETERS cText
    LOCAL lcSavePrinter, lcPrinter, lcOriginal, lcLabel, lcSetPrinter
    lcSetPrinter = SET("PRINTER")
    SET PRINTER OFF
    lcOrignal = SET("Printer",2)
    lcLabel = THIS.BuildLabel()
    IF VERSION(2) = 2
      lcSavePrinter = "LabelPrinter.MEM"
    ELSE
      lcSavePrinter= ADDBS(JUSTPATH(SYS(16,0)))+ ;
      "LabelPrinter.MEM"
    ENDIF
    IF FILE(lcSavePrinter)
      lcPrinter = FILETOSTR(lcSavePrinter)
    ELSE
      MESSAGEBOX("The next screen will let you " + ;
      "select a label printer...",32, ;
      _SCREEN.CAPTION, 10000 )
      lcPrinter = GETPRINTER()
      IF EMPTY( lcPrinter )
        MESSAGEBOX("Unable to print labels " + ;
        " with a label printer.", 16, ;
        _SCREEN.CAPTION )
        RETURN .F.
      ENDIF
    ENDIF
    SET SAFETY OFF
    STRTOFILE(lcPrinter,lcSavePrinter,0)
    SET PRINTER TO NAME "&lcPrinter"
    ???lcLabel && Write the string out to the device
    SET PRINTER TO NAME "&lcOrignal" && Restore the printer
  ENDPROC


  PROCEDURE BuildLabel
    LOCAL lcLabel, lcItemName
    *!* 04/05/03 13:17:37 nf 2: Shortened up the name
    *!*
    lcItemName = SUBSTR(THIS.ItemName,1,INT(20.3*1.6875))
    lcItemName = STRTRAN(lcItemName,'\','\\')
    lcItemName = STRTRAN(lcItemName,'"','\"')
    *!* Documentation follows in compiler IF below.
    *!* Do not change any of the lines within the
    *!* TextMerge block
    TEXT TO lcLabel TEXTMERGE NOSHOW
    R000,000
    O
    q350
    Q101,25+0
    S3
    N
    B15,22,0,UA0,1,2,62,B,<<'"'+TRIM(this.ItemUPC)+'"'>>
    A11,0,0,1,1,1,N,<<'"'+lcItemName+'"'>>
    A150,20,0,1,1,1,N,<<'"'+this.ItemProductID+'"'>>
    A155,37,0,2,1,1,N,"Rooster Brother"
    A210,62,0,2,1,1,N,<<'"'+LTRIM(this.ItemPrice)+'"'>>
    P<<TRANSFORM(this.Copies)>>,1

    ENDTEXT

RETURN lcLabel

    *!* Document the TextMerge. See EPL2_Manual.pdf for
    *!* all commands
    #IF .F.
      <<TRIM(TRANSFORM(THIS.COPIES))>>
      R000,000  && Set registration
      O      && Machine options
      q350    && Width
      Q101,25+0  && Height, Gap
      D15      && Density
      S3      && Speed
      N      && Clear buffer
      A15,3,0,1,1,1,N,"Licorice"  && ASCII
      A200,26,0,1,1,1,N,"11402"  && Item #
      A200,45,0,1,1,1,N,"My Retail Store"
      A210,73,0,1,1,1,N,"$"
      A230,71,0,1,1,1,N,"4.55"
      B10,26,0,UA0,2,2,49,N,"726562208042" && The UPC
      P1,1   && Print n Sets, n Labels each set
      && Necessary blank line
    #ENDIF
  ENDPROC


ENDDEFINE
*
*-- EndDefine: zebralabel
**************************************************
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform