;** PD_0388X *******************************************************************
;** Imprime a Digitacao do Pedido p/ Expedi‡Æo                                 *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido  em: 18/01/2019 por Bruno Carvalho         
;Ultima Alteracao: 21/01/2019 por Bruno Carvalho                  
;Motivo Alteracao: Retirado a exibi‡Æo do nome da pessoa na impressÆo do pedido de expedi‡Æo 
;Ultima Alteracao: 23/01/2019 por Bruno Carvalho                  
;Motivo Alteracao: Ajustes na impressÆo do pedido ao imprimir a observacao do item e adicioando a impressÆo da obs do pedido e alterado p/ modo paisagem
;Ultima Alteracao: 04/02/2019 por Bruno Carvalho                  
;Motivo Alteracao: Ordenar registros pelo artigo e adicionar razao social na frente do c¢digo da pessoa. 

;*******************************************************************************
;* Rotina para Checar Linha                                                    *
;*******************************************************************************
Proc ChecaLinha(PARAM)
Private TEMP

If Cont>=49
   Then If PARAM = "Final"
           Then 
           Else IMPRIME_LINHA=False
                Print File ARQIMP Spaces(2)+chr(192)+X+X+X+X+X+X+U+X+X+X+X+X+X+X+X+X+X+U+X+X+X+X+X+X+X+X+X+X+U+X+X+X+X+X+X+X+X+X+X+U+X+X+X+
                                          X+X+X+X+X+X+X+U+X+X+X+X+X+X+X+X+X+X+U+X+X+X+X+X+X+X+X+X+X+U+X+X+X+X+X+X+X+X+X+X+U+X+X+X+X+X+X+X+X+
                                          X+X+X+U+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+chr(217)+"\n"
        EndIf   
        Cont = 0
        PAG  = 0
        Print File ARQIMP "\f"     
        TEMP = True 
   Else IMPRIME_LINHA=True
        TEMP = False                                      
EndIf

Return TEMP

EndProc ;ChecaLinha()

;*******************************************************************************
;* Rotina para Imprimir Cabecalho                                              *
;*******************************************************************************
Proc Cabecalho()

PAG = 1
Moveto "PedidoC"

Print File ARQIMP CI_12CPP+CI_8LPP
Print File ARQIMP "\n"
Print File ARQIMP Spaces(2)+chr(218)+fill(X,130)+chr(191)+"\n"
Print File ARQIMP Spaces(2)+S+CI_INEG+Format("W85,AC","Ordem de Servi‡o")+Spaces(26)+FormaT("W21","Data OS: "+CI_FNEG+Format("D13",Today()))+S+"\n"
Print File ARQIMP Spaces(2)+chr(195)+fill(X,130)+chr(180)+"\n"

Print File ARQIMP Spaces(2)+S+Format("W70",CI_INEG+"Cliente: "+CI_FNEG+[Codigo]+" "+[Razao Social])+
                           Format("W68",CI_INEG+"Vendedor: "+CI_FNEG+[Codigo do Representante]+" "+[Nome Fantasia Represent])+S+"\n"
Print File ARQIMP Spaces(2)+S+Fill(" ",130)+S+"\n"                       
Print File ARQIMP Spaces(2)+        chr(195)+X+X+X+X+X+X+T+X+X+X+X+X+X+X+X+X+X+T+X+X+X+X+X+X+X+X+X+X+T+X+X+X+X+X+X+X+X+X+X+T+X+X+X+X+X+X+X+X+X+X+T+
                                   X+X+X+X+X+X+X+X+X+X+T+X+X+X+X+X+X+X+X+X+X+T+X+X+X+X+X+X+X+X+X+X+T+X+X+X+X+X+X+X+X+X+X+X+T+X+X+X+X+X+X+X+X+X+X+X+
                                   X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+chr(180)+"\n"
Print File ARQIMP Spaces(2)+        chr(179)+CI_INEG+"Artigo"+CI_FNEG+S+CI_INEG+"   Var    "+CI_FNEG+S+CI_INEG+"Quantidade"+CI_FNEG+S+CI_INEG+"Marca Tec."+
                                   CI_FNEG+S+CI_INEG+"Largura   "+CI_FNEG+S+CI_INEG+"Qtd Imp   "+CI_FNEG+S+CI_INEG+"Impresso? "+CI_FNEG+S+CI_INEG+
                                   "Bobinba   "+CI_FNEG+S+CI_INEG+"Calandrado?"+CI_FNEG+S+CI_INEG+"OBS                               "+CI_FNEG+chr(179)+"\n"
Print File ARQIMP Spaces(2)+        chr(195)+X+X+X+X+X+X+M+X+X+X+X+X+X+X+X+X+X+M+X+X+X+X+X+X+X+X+X+X+M+X+X+X+X+X+X+X+X+X+X+M+X+X+X+X+X+X+X+X+X+X+M+X+X+
                                   X+X+X+X+X+X+X+X+M+X+X+X+X+X+X+X+X+X+X+M+X+X+X+X+X+X+X+X+X+X+M+X+X+X+X+X+X+X+X+X+X+X+M+X+X+X+X+X+X+X+X+X+X+X+X+X+X+
                                   X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+chr(180)+"\n"

EndProc ;Cabecalho()

;*******************************************************************************
;* Rotina de Observa‡Æo                           para Impressao do Relatorio                                          *
;*******************************************************************************
Proc Observacao()

Release Vars ARRAY_OBS 
DynArray ARRAY_OBS[]           
 
CONTADOR = 0    

If TITULO_OBS<>"" Then CARACTER_OBS = CARACTER_OBS - Len(TITULO_OBS) EndIf        
CONTROL  = OBS

PosI     = Search("\n",CONTROL)
If PosI > 0
   Then While PosI > 0
          AUX     = SubStr(CONTROL,1,PosI-1)
          CONTROL = SubStr(CONTROL,PosI+1,Len(CONTROL))
          LINHA   = Int(Len(AUX) / CARACTER_OBS)
                    If (Len(AUX) / CARACTER_OBS) - LINHA > 0
                       Then LINHA = LINHA + 1
                    EndIf
          LINHA_OBS = LINHA_OBS + LINHA      
          For i From 1 To LINHA
            CONTADOR = CONTADOR + 1
            If i = 1
               Then INI = 1
               Else INI = ((i-1)*CARACTER_OBS)+1
            EndIf
            If CONTADOR = 1
               Then ARRAY_OBS[CONTADOR] = AlinhM(StrVal(CONTADOR),3)+TITULO_OBS
               Else ARRAY_OBS[CONTADOR] = AlinhM(StrVal(CONTADOR),3)+Spaces(Len(TITULO_OBS))
            EndIf
            ARRAY_OBS[CONTADOR] = ARRAY_OBS[CONTADOR] + Ltrim(Rtrim(SubStr(AUX,INI,CARACTER_OBS)))
          EndFor    
          PosI      = Search("\n",CONTROL)
        EndWhile
        If CONTROL<>"" 
           Then LINHA = Int(Len(CONTROL) / CARACTER_OBS)
                If (Len(CONTROL) / CARACTER_OBS) - LINHA > 0
                   Then LINHA = LINHA + 1
                EndIf
                For i From 1 To LINHA
                   CONTADOR = CONTADOR + 1
                   If i = 1
                      Then INI = 1
                      Else INI = ((i-1)*CARACTER_OBS)+1
                   EndIf 
                   If CONTADOR = 1
                      Then ARRAY_OBS[CONTADOR] = AlinhM(StrVal(CONTADOR),3)+TITULO_OBS
                      Else ARRAY_OBS[CONTADOR] = AlinhM(StrVal(CONTADOR),3)+Spaces(Len(TITULO_OBS))
                   EndIf
                   ARRAY_OBS[CONTADOR] = ARRAY_OBS[CONTADOR] + Ltrim(Rtrim(SubStr(CONTROL,INI,CARACTER_OBS)))     
                EndFor 
        EndIf           
     Else LINHA = Int(Len(CONTROL) / CARACTER_OBS)
                If (Len(CONTROL) / CARACTER_OBS) - LINHA > 0
                   Then LINHA = LINHA + 1
                EndIf       
        For i From 1 To LINHA
           CONTADOR = CONTADOR + 1
           If i = 1
              Then INI = 1
              Else INI = ((i-1)*CARACTER_OBS)+1
           EndIf 
           If CONTADOR = 1
              Then ARRAY_OBS[CONTADOR] = AlinhM(StrVal(CONTADOR),3)+TITULO_OBS
              Else ARRAY_OBS[CONTADOR] = AlinhM(StrVal(CONTADOR),3)+Spaces(Len(TITULO_OBS))
           EndIf
           ARRAY_OBS[CONTADOR] = ARRAY_OBS[CONTADOR] + Ltrim(Rtrim(SubStr(CONTROL,INI,CARACTER_OBS)))     
        EndFor
EndIf    
NLINHA = LINHA_OBS  

EndProc ;Observacao()

;*******************************************************************************
;* Rotina para Impressao do Relatorio                                          *
;*******************************************************************************
Proc IMPPED_PAISAGEM()
private regitens, regsdestq, anoref, mesref, refeitem, Desccomp, ctmedio, s1, s2, s3, kv

;************************* IMPRESSAO DO CABECALHO *****************************
PAG = 0

S         = chr(179) ;Ý
X         = chr(196) ;-
T         = chr(194) ;-
U         = chr(193) ;-
M         = chr(197) ;+

TITULO_OBS    = ""
IMPRIME_LINHA = False
CARACTER_OBS  = 34                              
LINHA_OBS     = 0
NPED          = [Numero do Pedido]

;************************** IMPRESSAO DOS ITENS ********************************

Moveto "PedidoC"
Formkey

Tab_Temp=Cria_Temp(PrivDir())
{Create} TypeIn Tab_Temp Enter
If MenuChoice()="Cancel" Then {OK} EndIf
Moveto [Field Name] TypeIn "Codigo do Item" Enter TypeIn "A10" Down
Moveto [Field Name] TypeIn "Sequencia"      Enter TypeIn "S" Down 
Moveto [Field Name] TypeIn "Artigo"         Enter TypeIn "A12"
Do_it!
    
Coedit Tab_Temp,"PedidoI"
Moveto [Numero do Pedido]
Locate NPED
If RetVal
   Then While [Numero do Pedido] = NPED
          Moveto Tab_Temp
          If [Codigo do Item]<>""
             Then End Down
          EndIf     
          GetRecord "\\Sistemas\\Estoque\\Iten_Tec" [Pedidoi->Codigo do Item] to regitens
          If Not retval
             then artigo = "????"
             else artigo = regitens["artigo"]
          Endif
          [Codigo do Item] = [Pedidoi->Codigo do Item] 
          [Sequencia     ] = [Pedidoi->Item do Pedido]
          If type(numval(artigo))="N" Then artigo = AlinhM(strVal(numval(artigo)),12) EndIf
          ;foi necess rio alinhar p/ realizar a ordena‡Æo dos valores do artigo ao executar o SORT 
          [Artigo        ] = artigo 
          UnLockRecord
          Moveto "PedidoI"
          Skip
          If Eot() Then QuitLoop EndIf
        EndWhile
EndIf
Do_it!
Moveto "PedidoI" ClearImage
Moveto Tab_Temp  ClearImage
Sort Tab_Temp On "Artigo" ClearImage

View Tab_Temp                        
Cont=0
Scan
   COD_ITEM = [Codigo do Item]
   SEQ_ITEM = [Sequencia     ]
   ARTIGO   = [Artigo        ] 
   
   GetRecord "\\Sistemas\\Vendas\\PedidoI" NPED,SEQ_ITEM To REG_ITEM
   If Not RetVal
      Then Loop
   EndIf   
   Cont=Cont+2
  
   If IMPRIME_LINHA 
      Then Imprime_Final=True 
           Print File ARQIMP Spaces(2)+chr(195)+X+X+X+X+X+X+M+X+X+X+X+X+X+X+X+X+X+M+X+X+X+X+X+X+X+X+X+X+M+X+X+X+X+X+X+X+X+X+X+M+X+X+
                                       X+X+X+X+X+X+X+X+M+X+X+X+X+X+X+X+X+X+X+M+X+X+X+X+X+X+X+X+X+X+M+X+X+X+X+X+X+X+X+X+X+M+X+X+X+X+X+
                                       X+X+X+X+X+X+M+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+chr(180)+"\n"
   EndIf   
   
   If PAG = 0
      Then Cabecalho()
           Moveto Tab_Temp
   EndIf       

   GetRecord "\\Sistemas\\Estoque\\Iten_Tec" COD_ITEM to regitens
   If Not retval
      then artigo = "????"
      else artigo = regitens["artigo"]
   Endif

   ;GetRecord "\\Sistemas\\Estoque\\Itens" [PedidoI->Codigo do Item] to regitens
   ;If Not retval
   ;   then cor = "????"
   ;   else cor = regitens["codigo da cor_tecido"]
   ;Endif      
   
   Print File ARQIMP Spaces(2)+S
   Print File ARQIMP Format("W6,AC",ARTIGO)+S
   Print File ARQIMP Format("W10,AC",REG_ITEM["Variacoes"])+S
   Print File ARQIMP Format("W10.2",REG_ITEM["Quantidade"])+S   ;verrrrrrr
   
   Print File ARQIMP Spaces(10)+S
   Print File ARQIMP Spaces(10)+S
   Print File ARQIMP Spaces(10)+S
   Print File ARQIMP Spaces(10)+S
   Print File ARQIMP Spaces(10)+S
   Print File ARQIMP Spaces(11)+S
    
   OBS = REG_ITEM["Observacao_Item"]
   If OBS<>""
      Then Observacao()
           XX = Spaces(2)+chr(179)+Spaces(6)+S+Spaces(10)+S+Spaces(10)+S+Spaces(10)+S+Spaces(10)+S+Spaces(10)+S+Spaces(10)+S+Spaces(10)+S+Spaces(11)+S
           If IsAssigned(ARRAY_OBS)
              Then For i From 1 To DynArraySize(ARRAY_OBS)
                     Switch
                       Case i=1  : Print File ARQIMP Format("W"+StrVal(CARACTER_OBS),SubStr(ARRAY_OBS[i],4,Len(ARRAY_OBS[i])))+S+"\n"
                                   If ChecaLinha("")
                                      Then If i<>DynArraySize(ARRAY_OBS) Then Cabecalho() Moveto Tab_Temp EndIf
                                   EndIf
                       OtherWise : Cont=Cont+1
                                   Print File ARQIMP XX + Format("W"+StrVal(CARACTER_OBS),SubStr(ARRAY_OBS[i],4,Len(ARRAY_OBS[i])))+S+"\n"
                                   If ChecaLinha("")
                                      Then If i<>DynArraySize(ARRAY_OBS) Then Cabecalho() Moveto Tab_Temp EndIf
                                   EndIf
                     EndSwitch
                   EndFor
                    
           EndIf
      Else Print File ARQIMP Spaces(CARACTER_OBS)+S+"\n"
           ChecaLinha("")
   EndIf
   Imprime_Final=False   
EndScan

If Not Imprime_Final
   Then Print File ARQIMP Spaces(2)+chr(192)+X+X+X+X+X+X+U+X+X+X+X+X+X+X+X+X+X+U+X+X+X+X+X+X+X+X+X+X+U+X+X+X+X+X+X+X+X+X+X+U+X+X+X+
                                    X+X+X+X+X+X+X+U+X+X+X+X+X+X+X+X+X+X+U+X+X+X+X+X+X+X+X+X+X+U+X+X+X+X+X+X+X+X+X+X+U+X+X+X+X+X+X+X+
                                    X+X+X+X+U+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+chr(217)+"\n"
EndIf

Moveto "PedidoC"
Moveto [Numero do Pedido]
Locate NPED
FormKey
Moveto "PedidoI"

OBS = [PedidoC->Observacao do Pedido]
If OBS<>""
   Then TITULO_OBS    = "OBS.: "  
        CARACTER_OBS  = 130                              
        LINHA_OBS     = 0
        Observacao()
        If IsAssigned(ARRAY_OBS)
           Then For i From 1 To DynArraySize(ARRAY_OBS)
                  If i=1 Then  Cont=Cont+1 Print File ARQIMP "\n" EndIf
                  Cont=Cont+1
                  Print File ARQIMP Spaces(2)+Format("W"+StrVal(CARACTER_OBS),SubStr(ARRAY_OBS[i],4,Len(ARRAY_OBS[i])))+"\n"
                  If ChecaLinha("Final") And i<>DynArraySize(ARRAY_OBS)
                     Then Cabecalho() 
                          Moveto "PedidoI" 
                  EndIf
                EndFor
       EndIf
EndIf
                                               
EndProc ;IMPPED_PAISAGEM()

;*******************************************************************************
;* Rotina para Impressao do Relatorio                                          *
;*******************************************************************************
Proc IMPPED_RETRATO()
private regitens, regsdestq, anoref, mesref, refeitem, Desccomp, ctmedio, s1, s2, s3, kv

;************************* IMPRESSAO DO CABECALHO *****************************
PAG = 0

S         = chr(179) ;Ý
X         = chr(196) ;-
T         = chr(194) ;-
U         = chr(193) ;-
M         = chr(197) ;+

IMPRIME_LINHA=False

Moveto "PedidoI"                          
Cont=1
Scan
   If IMPRIME_LINHA 
      Then Imprime_Final=True 
           Print File ARQIMP Spaces(2)+chr(195)+X+X+X+X+X+X+M+X+X+X+X+X+X+X+X+X+X+M+X+X+X+X+X+X+X+X+X+X+M+X+X+X+X+X+X+X+X+X+X+M+X+X+
                                       X+X+X+X+X+X+X+X+M+X+X+X+X+X+X+X+X+X+X+M+X+X+X+X+X+X+X+X+X+X+M+X+X+X+X+X+X+X+X+X+X+M+X+X+X+X+X+
                                       X+X+X+X+X+X+M+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+chr(180)+"\n"
   EndIf   
   
   If PAG = 0
      Then PAG = 1
           Moveto "PedidoC"

           Print File ARQIMP CI_12CPP+CI_8LPP
           Print File ARQIMP "\n"
           Print File ARQIMP Spaces(2)+chr(218)+fill(X,130)+chr(191)+"\n"
           Print File ARQIMP Spaces(2)+S+CI_INEG+Format("W85,AC","Ordem de Servi‡o")+Spaces(26)+FormaT("W21","Data OS: "+CI_FNEG+Format("D13",Today()))+S+"\n"
           Print File ARQIMP Spaces(2)+chr(195)+fill(X,130)+chr(180)+"\n"
          
           Print File ARQIMP Spaces(2)+S+Format("W70",CI_INEG+"Cliente: "+CI_FNEG+[Codigo])+
                                       Format("W68",CI_INEG+"Vendedor: "+CI_FNEG+[Codigo do Representante]+" "+[Nome Fantasia Represent])+S+"\n"
           Print File ARQIMP Spaces(2)+S+Fill(" ",130)+S+"\n"                       
           Print File ARQIMP Spaces(2)+        chr(195)+X+X+X+X+X+X+T+X+X+X+X+X+X+X+X+X+X+T+X+X+X+X+X+X+X+X+X+X+T+X+X+X+X+X+X+X+X+X+X+T+X+X+X+X+X+X+X+X+X+X+T+
                                               X+X+X+X+X+X+X+X+X+X+T+X+X+X+X+X+X+X+X+X+X+T+X+X+X+X+X+X+X+X+X+X+T+X+X+X+X+X+X+X+X+X+X+X+T+X+X+X+X+X+X+X+X+X+X+X+
                                               X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+chr(180)+"\n"
           Print File ARQIMP Spaces(2)+        chr(179)+"Artigo"+S+"Var       "+S+"Quantidade"+S+"Marca Tec."+S+"Largura   "+S+
                                               "Qtd Imp   "+S+"Impresso? "+S+"Bobinba   "+S+"Calandrado?"+S+
                                               "OBS                               "+chr(179)+"\n"
           Print File ARQIMP Spaces(2)+        chr(195)+X+X+X+X+X+X+M+X+X+X+X+X+X+X+X+X+X+M+X+X+X+X+X+X+X+X+X+X+M+X+X+X+X+X+X+X+X+X+X+M+X+X+X+X+X+X+X+X+X+X+M+X+X+
                                               X+X+X+X+X+X+X+X+M+X+X+X+X+X+X+X+X+X+X+M+X+X+X+X+X+X+X+X+X+X+M+X+X+X+X+X+X+X+X+X+X+X+M+X+X+X+X+X+X+X+X+X+X+X+X+X+X+
                                               X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+chr(180)+"\n"
           Moveto "PedidoI"
   EndIf       

   GetRecord "\\Sistemas\\Estoque\\Iten_Tec" [PedidoI->Codigo do Item] to regitens
   If Not retval
      then artigo = "????"
      else artigo = regitens["artigo"]
   Endif
   
   ;GetRecord "\\Sistemas\\Estoque\\Itens" [PedidoI->Codigo do Item] to regitens
   ;If Not retval
   ;   then cor = "????"
   ;   else cor = regitens["codigo da cor_tecido"]
   ;Endif      
   
   Print File ARQIMP Spaces(2)+S
   Print File ARQIMP Format("W6",artigo)+S
   Print File ARQIMP Format("W10",[Variacoes])+S
   Print File ARQIMP Format("W10",[Quantidade])+S
   
   Print File ARQIMP Spaces(10)+S
   Print File ARQIMP Spaces(10)+S
   Print File ARQIMP Spaces(10)+S
   Print File ARQIMP Spaces(10)+S
   Print File ARQIMP Spaces(10)+S
   Print File ARQIMP Spaces(11)+S
   
   Print File ARQIMP Format("W34",[Observacao_Item])+S+"\n"
   
   Imprime_Final=False
   Cont=Cont+2
   If Cont=79
     Then IMPRIME_LINHA=False
          PAG = 0
          Print File ARQIMP Spaces(2)+chr(192)+X+X+X+X+X+X+U+X+X+X+X+X+X+X+X+X+X+U+X+X+X+X+X+X+X+X+X+X+U+X+X+X+X+X+X+X+X+X+X+U+X+X+X+
                                    X+X+X+X+X+X+X+U+X+X+X+X+X+X+X+X+X+X+U+X+X+X+X+X+X+X+X+X+X+U+X+X+X+X+X+X+X+X+X+X+U+X+X+X+X+X+X+X+X+
                                    X+X+X+U+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+chr(217)+"\n"
          Print File ARQIMP "\f"
     Else IMPRIME_LINHA=True                                      
   EndIf
EndScan
If Not Imprime_Final
   Then Print File ARQIMP Spaces(2)+chr(192)+X+X+X+X+X+X+U+X+X+X+X+X+X+X+X+X+X+U+X+X+X+X+X+X+X+X+X+X+U+X+X+X+X+X+X+X+X+X+X+U+X+X+X+
                                    X+X+X+X+X+X+X+U+X+X+X+X+X+X+X+X+X+X+U+X+X+X+X+X+X+X+X+X+X+U+X+X+X+X+X+X+X+X+X+X+U+X+X+X+X+X+X+X+
                                    X+X+X+X+U+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+chr(217)+"\n"
EndIf
                                    
EndProc ;IMPPED_RETRATO()

;*******************************************************************************
;* Rotina Principal                                                            *
;*******************************************************************************
AGUARDE("Imprimindo Pedido -> "+PEDIDO)

MODO_PAISAGEM=True

ArqImp=PrivDir()+"PD_0388X.Txt"
If IsFile(ArqImp)
   Then Deleta_Arquivo(ARQIMP)
EndIf

If MODO_PAISAGEM
   Then Impressao_Orientacao="Paisagem"
        IMPPED_PAISAGEM()
   Else IMPPED_RETRATO()
EndIf   

ImpriArq(ARQIMP)
Release Procs IMPPED_PAISAGEM,IMPPED_RETRATO
