;** ET_Z051A *******************************************************************
;* Monta Etiqueta p/ Impressora Termica - Zebra - EAN13 com Pre‡o              *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido    : 07/11/2016 por Bruno Carvalho
;Ultima Alteracao: 07/11/2018 por Bruno Carvalho
;Motivo Alteracao: Ajustes padrÆo p/ codigo de barras EAN8, EAN13 ou COD128 

;*******************************************************************************
Proc Monta_Etiqueta()
Moveto "Answer"

Print File Arquivo "O\n"
Print File Arquivo "N\n"
Print File Arquivo "q840\n"
Print File Arquivo "Q104,24+\n"
Print File Arquivo "S2\n"
Print File Arquivo "D8\n"
Print File Arquivo "ZT\n"     
                 
If Not IsBlank(CDBAR[1])
   Then Switch
          Case Search("EAN13",TPBARRA[1])>0 : Print File Arquivo "B50,10,0,E30,3,2,60,B,\""+CDBAR[1]+"\"\n" 
          Case Search("EAN8",TPBARRA[1])>0  : Print File Arquivo "B50,10,0,E80,3,2,60,B,\""+CDBAR[1]+"\"\n"
          OtherWise                         : Print File Arquivo "B50,10,0,1,3,2,60,B,\""+CDBAR[1]+"\"\n"
        EndSwitch 
EndIf   
If Not IsBlank(CDBAR[2])
   Then Switch
          Case Search("EAN13",TPBARRA[2])>0 : Print File Arquivo "B470,10,0,E30,3,2,60,B,\""+CDBAR[2]+"\"\n" 
          Case Search("EAN8",TPBARRA[2])>0  : Print File Arquivo "B470,10,0,E80,3,2,60,B,\""+CDBAR[2]+"\"\n"
          OtherWise                         : Print File Arquivo "B470,10,0,1,3,2,60,B,\""+CDBAR[2]+"\"\n"
        EndSwitch 
EndIf     

If CDBAR[1]=CDBAR[2]
   Then Print File Arquivo "P"+StrVal(CR)+"\n"
        ce=ce+((CR-1)*3)
   Else Print File Arquivo "P1\n"
EndIf

ne=2

EndProc ;Monta_Etiqueta()

;*******************************************************************************
;* Monta Comandos p/ Impressora Termica                                        *
;*******************************************************************************
Proc Monta_Comandos()

Release Vars CDBAR, TPBARRA

Array TPBARRA[2]
Array   CDBAR[2]

Arquivo=PrivDir()+"ET_Z051A.ejf"
Deleta_Arquivo(Arquivo)
       
ne=2   
Coedit "Answer"
Scan
  te=[Quantidade]
  If (te-(2-ne))>2
     Then CR=Int((te-(2-ne))/2)
     Else CR=1
  EndIf
  ce=0
  While True
    ce=ce+1
    ne=ne+1
    If ne=3
       Then For i From 1 To 2
              CDBAR[i]=""
            EndFor
            ne=1
    EndIf
  TPBARRA[ne]=Upper([Tipo Codigo_Barras])  
    CDBAR[ne]=[Codigo de Barras ]
    If ne=2   Then Monta_Etiqueta() EndIf
    If ce>=te Then QuitLoop         EndIf
  EndWhile
EndScan
If ne<2 Then Monta_Etiqueta() EndIf
Do_It!
ClearAll
ImpriArq(Arquivo)

Sleep 700
Deleta_Arquivo(Arquivo)
ClearAll
EndProc

Monta_Comandos()
Release Procs Monta_Etiqueta,Monta_Comandos
