;* ;** Et_Z422  ****************************************************************
;* Monta Etiqueta p/ Imp. T‚rmica - Zebra                         * Modelo 119 *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido    : 17/10/2018 por Bruno Carvalho
;Ultima Alteracao: 07/11/2018 por Bruno Carvalho
;Motivo Alteracao: Ajustes padrÆo p/ codigo de barras EAN8, EAN13 ou COD128 

;*******************************************************************************
; Monta Etiqueta                                                              **
;*******************************************************************************
Proc Monta_Etiqueta()
private opf

Print File Arquivo "O\n"
Print File Arquivo "N\n"
Print File Arquivo "q872\n"  
Print File Arquivo "Q400,40\n"
Print File Arquivo "S2\n"
Print File Arquivo "D12\n"
Print File Arquivo "ZT\n"

TM_CODBARRA = "G"

Print File Arquivo "A150,020,1,3,1,1,N,\""+LINHA1 +"\"\n"
Print File Arquivo "A120,020,1,3,1,1,N,\""+LINHA2 +"\"\n"
If TM_CODBARRA="G"
   Then Switch
          Case Search("EAN13",TPBARRA)>0 : Print File Arquivo "B100,030,1,E30,3,3,75,B,\""+LINHA3+"\"\n" 
          Case Search("EAN8",TPBARRA)>0  : Print File Arquivo "B100,030,1,E80,3,3,75,B,\""+LINHA3+"\"\n"
          OtherWise                      : Print File Arquivo "B100,065,1,1,3,3,65,B,\""+LINHA3+"\"\n" 
        EndSwitch
   Else Switch
          Case Search("EAN13",TPBARRA)>0 : Print File Arquivo "B090,090,1,E30,2,3,55,B,\""+LINHA3+"\"\n" 
          Case Search("EAN8",TPBARRA)>0  : Print File Arquivo "B090,090,1,E80,2,3,55,B,\""+LINHA3+"\"\n"
          OtherWise                      : Print File Arquivo "B095,110,1,1,2,3,45,B,\""+LINHA3+"\"\n"    
        EndSwitch  
EndIF
    
Print File Arquivo "P1\n"

EndProc                 

;*******************************************************************************
;* Monta Comandos p/ Impressora Termica                                        *
;*******************************************************************************
Proc Monta_Comandos()
If IsAssigned(DITEA)
   Then Release Vars LINHA1, LINHA2, LINHA3, TPBARRA  
EndIf

Arquivo=PrivDir()+"Et_Z422.Ext"
Deleta_Arquivo(Arquivo)

Coedit "Answer"
Scan  
  te=[Quantidade]
  ce=0
  While True            
    ce=ce+1

   TPBARRA = Upper([Tipo Codigo_Barras])
    LINHA1 = SubStr([Descricao do Item],01,25)
    LINHA2 = SubStr([Descricao do Item],26,25)
    LINHA3 = [Codigo de Barras]    
    
    Monta_Etiqueta()
    If ce>=te Then QuitLoop EndIf
  EndWhile
EndScan
Do_It!
ClearAll

ImpriArq(Arquivo)

Sleep 700
Deleta_Arquivo(Arquivo)
ClearAll
EndProc

Monta_Comandos()
Release Procs Monta_Etiqueta,Monta_Comandos
