;** RE_I159 ********************************************************************
;* Monta Etiqueta p/ Impressora Termica - Zebra - INMETRO Carol                *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido    : 25/11/2019 por Anivel Augusto Rodrigues
;Ultima Alteracao:   /  /     por 
;Motivo Alteracao: 

;ETIQUETA DE INMETRO -> RE_0010E

;*******************************************************************************
Proc Monta_Etiqueta()

Moveto "Answer"

If Not IsBlank(DITEA[1])
   Then Print File Arquivo "A172,100,1,2,2,1,N,\""+DITEA[1]+"\"\n"   ;1mm = 8dots       
EndIf
If Not IsBlank(DITEA[2])
   Then Print File Arquivo "A449,100,1,2,2,1,N,\""+DITEA[2]+"\"\n"
EndIf
If Not IsBlank(DITEA[3])
   Then Print File Arquivo "A732,100,1,2,2,1,N,\""+DITEA[3]+"\"\n"  
EndIf

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

;*******************************************************************************
;* Monta Comandos p/ Impressora Termica                                        *
;*******************************************************************************
Proc Monta_Comandos()
If IsAssigned(DITEA)
   Then Release Vars DITEA
EndIf
Array DITEA[3]

Arquivo="RE_I159.ejf"
Deleta_Arquivo(Arquivo)

Print File Arquivo "O\n"
Print File Arquivo "N\n"
Print File Arquivo "q824\n"
Print File Arquivo "Q400,24+\n"
Print File Arquivo "S2\n"
Print File Arquivo "D12\n"
Print File Arquivo "ZB\n"
  
ne=3
Coedit "Answer"
Scan
  numero = [INMETRO   ]
  te     = [Quantidade]
  If (te-(3-ne))>3
     Then CR=Int((te-(3-ne))/3)
     Else CR=1
  EndIf
  ce=0
  While True
    ce=ce+1
    ne=ne+1        
    If ne=4
       Then For i From 1 To 3
              DITEA[i]=""
            EndFor
            ne=1
    EndIf
    DITEA[ne]=numero
    If ne=3   Then Monta_Etiqueta() EndIf
    If ce>=te Then QuitLoop         EndIf
  EndWhile
EndScan
If ne<3 Then Monta_Etiqueta() EndIf
Do_It!
ClearAll

ImpriArq(Arquivo)

Sleep 700
Deleta_Arquivo(Arquivo)
ClearAll
EndProc

Monta_Comandos()
Release Procs Monta_Etiqueta,Monta_Comandos
