

Proc rptini()
grava("<?xml version="1.0" encoding="utf-8"?>")
grava("<TfrxReport Version="4.3" DotMatrixReport="True" IniFile="\Software\Fast Reports" PreviewOptions.Buttons="4095" PreviewOptions.Zoom="1" PrintOptions.Printer="Padrão" PrintOptions.PrintOnSheet="0" ReportOptions.CreateDate="39463,5833089005" ReportOptions.Description.Text="" ReportOptions.LastChange="39673,415805625" ScriptLanguage="PascalScript" ScriptText.Text="var FId_Pessoas: Integer;                                                    &#13;&#10;&#13;&#10;procedure MasterData1OnBeforePrint(Sender: TfrxComponent);&#13;&#10;var Visivel:Boolean;                                &#13;&#10;begin&#13;&#10;  If not DB_Principal.IsEmpty&#13;&#10;     Then begin                                           &#13;&#10;            Visivel := &#60;DB_Principal.&#34;ID_PESSOAS&#34;&#62; &#60;&#62; FId_Pessoas;                                                          &#13;&#10;            DB_PrincipalID_PESSOAS.Visible := Visivel;&#13;&#10;            DB_PrincipalRAZAO_SOCIAL.Visible := Visivel;&#13;&#10;            DB_PrincipalCIDADE.Visible := Visivel;&#13;&#10;            DB_PrincipalTELEFONE.Visible := Visivel;&#13;&#10;            DB_PrincipalPRIMEIRA_COMPRA.Visible := Visivel;                                   &#13;&#10;            DB_PrincipalULTIMA_COMPRA.Visible := Visivel;                                                &#13;&#10;            FId_Pessoas := &#60;DB_Principal.&#34;ID_PESSOAS&#34;&#62;;&#13;&#10;          end;                      &#13;&#10;end;&#13;&#10;&#13;&#10;procedure ReportOnStartReport(Sender: TfrxComponent);&#13;&#10;begin&#13;&#10;  DB_Principal.Active := False;&#13;&#10;  DB_Principal.SQL.Add(' ORDER BY ');    &#13;&#10;  If &#60;ORDEM_TIPO&#62; = 'Alfabetica'&#13;&#10;     Then DB_Principal.SQL.Add('(CADA_PESSOAS.RAZAO_SOCIAL)')&#13;&#10;     Else DB_Principal.SQL.Add('(CADA_PESSOAS.ID_PESSOAS)');  &#13;&#10;  Database.Params[6] := GetServidorPath;&#13;&#10;  DB_Principal.Active := True;&#13;&#10;  If DB_Principal.IsEmpty&#13;&#10;     Then begin&#13;&#10;            MSG_SemRegistros;&#13;&#10;            Engine.StopReport;&#13;&#10;          end;      &#13;&#10;end;&#13;&#10;&#13;&#10;begin&#13;&#10;FId_Pessoas := 0;                                      &#13;&#10;end." OnStartReport="ReportOnStartReport" PropData="044C65667403C80003546F70020708446174617365747301010C3200000020446174615365743D2244425F5072696E636970616C2220446174615365744E616D653D2244425F5072696E636970616C220000095661726961626C65730100055374796C650100">")
endproc

Proc rptfim()
grava("  </TfrxReportPage>")
grava("</TfrxReport>")
endproc


Proc Page_Header()

grava("    <TfrxPageHeader Name="Cabecalho" Height="204" Left="0" Top="17" Width="1248">")
grava("      <TfrxDMPMemoView Name="DMPMemo2"  Left="0"      Top="17" Width="1219,2" Height="17" DisplayFormat.DecimalSeparator="," FontStyle="32" ParentFont="False" Text="-------------------------------------------------------------------------------------------------------------------------------"/>")
grava("      <TfrxDMPMemoView Name="DMPMemo18" Left="739,2"  Top="34" Width="374,4"  Height="17" DisplayFormat.DecimalSeparator="," DisplayFormat.FormatStr="False,True" DisplayFormat.Kind="fkBoolean" FontStyle="32" HAlign="haRight" ParentFont="False" Text="Emissao: [Date #dd.mm.yyyy] - [Time #hh:mm:ss]"/>")
grava("      <TfrxDMPMemoView Name="DMPMemo20" Left="1123,2" Top="34" Width="96"     Height="17" DisplayFormat.DecimalSeparator="," FontStyle="32" ParentFont="False" Text="Pag.:[Page]"/>")
grava("      <TfrxDMPMemoView Name="DMPMemo1"  Left="0"      Top="51" Width="1219,2" Height="17" DisplayFormat.DecimalSeparator="," FontStyle="32" ParentFont="False" Text="-------------------------------------------------------------------------------------------------------------------------------"/>")
grava("      <TfrxDMPMemoView Name="DMPMemo19" Align="baWidth" Left="0" Top="102" Width="1248" Height="17" DisplayFormat.DecimalSeparator="," FontStyle="32" HAlign="haCenter" ParentFont="False" Text="Titulos a Receber/Cliente/Cobrador - Periodo de [P_DATA_INI] ate [P_DATA_FIM]"/>")
      

Endproc

Proc Page_Footer()
grava("    <TfrxPageFooter Name="FimPagina" Height="17" Left="0" Top="238" Width="1248">")
grava("      <TfrxDMPMemoView Name="DMPMemoRodape" Left="1075,2" Top="0" Width="153,6" Height="17" DisplayFormat.DecimalSeparator="," Text="VISE INFORMµTICA"/>")
grava("    </TfrxPageFooter>")
Endproc


Proc Group_Header()


Endproc

Proc Group_Footer()


Endproc

Proc Master_Data()



Endproc





proc grava(s)
 FileWrite Append arqtxt From s+"\n"
Endproc


Proc gravacampo()

Switch
  case nf="": 
       tm1=len(s)
       tm2=len(ltrim(s))

       If tm2=0 
          then Return
       endif
         
       nc=nc+(tm1-tm2)
       tm=tm-(tm1-tm2)
       s=ltrim(s)
       
       Switch
         case s="ate "                   : s="at"+chr(130)+" "       
         case s="Emissao: "              : s="Emiss„o: "       
       EndSwitch
       
  otherwise: 
       if subStr(nf,1,1)="["
          Then If searchfrom("[",nf,2)=0
                  Then nf=xtrim(nf,"[]")
               EndIf
       Endif

       if not isfield(nf)
          then Switch
                 case nf="NOMEMPRESA"                        : tpf="varprg" 
                 case substr(nf,1,3)="CI_"                   : tpf="varprg" 
                 case substr(nf,1,4)="VSDG"                  : tpf="varprg" 
                 case nf="Current time"                      : tpf="varrpt" 
                 case nf="Current page number"               : tpf="varrpt"
                 case nf="Format(\"D13\",Today())"           : tpf="varrpt" nf="today()"
                 case nf="Format(\"D13\",VSDGDTINI)"         : tpf="varprg" nf="VSDGDTINI" s="DD/MM/AAAA"
                 case nf="Format(\"D13\",VSDGDTFIM)"         : tpf="varprg" nf="VSDGDTFIM" s="DD/MM/AAAA"
                 case search("FORMAT",upper(nf))>0           : tpf="calculado"

                 case search("TOTAL FOR ",upper(nf))>0       : 
                      nf=substr(nf,10,Len(nf))
                      pos=search(",",nf)
                      tpf="sum"+substr(nf,pos,30)
                      nf=substr(nf,1,pos-1)
                 otherwise                                   : tpf="varprg" 
               EndSwitch
      endif

EndSwitch


If s<>"" then s="\""+s+"\"" endif




Grava(AlinhM(StrVal(nlb),2)+","+AlinhM(StrVal(nc),3) +"|"+ Completa(tpf,20," ") +"|"+ Completa(nf,80," ") +"|"+ Completa(tf,07," ") +"|" +Alinhm(strval(tm),3) +"|" +s)

Endproc


proc isfield(campo)
private i

for i from 1 to NFields(Tabela)
  if upper(array_campos[i])=upper(campo)
     then tf=array_tipos[i]
          switch
            case substr(tf,1,1)="A"  : tf="texto"
            case substr(tf,1,1)="M"  : tf="memo"
            case tf            ="N"  : tf="decimal"
            case tf            ="S"  : tf="inteiro"
            case tf            ="$"  : tf="moeda"
            case tf            ="D"  : tf="data"
          endswitch
          tpf="field"
          return true
  endif   
endfor 
return false
endproc

;;;Rotina principal
AutoLib="\\Sistemas\\Cadastro\\Bibliot,\\Sistemas\\Cadastro\\Bib_Show"

setdir "\\sistemas\\vendas"
tabela="\\sistemas\\vendas\\rm_3100"

{Report} {Change} 

typeIn tabela enter 
;rpt=menuchoice()
rpt="?"
{R}
titrpt=menuchoice() Enter

TableInfo Tabela Fields to Array_campos, Array_tipos

arqtxt="\\sistemas\\cadastro\\testrpt.txt"

FileWrite arqtxt From ""

{setting} {pagelayout} {length} 
pl=menuchoice()
enter

pw=pagewidth()

Grava("tabela    ="+tabela)
Grava("report    ="+rpt)
Grava("nome      ="+titrpt)
Grava("pagewidth ="+strval(pw))
Grava("pagelength="+strval(pl))

nband=""
While True

  nl =rowno()

  If BandInfo()<>nband
     Then nband=BandInfo()
          Grava("")
          Grava("* "+nband)
          nlb=0
  EndIf   

  t=cursorline()
  If Search(Chr(196),t)=0 And
     (Search(Chr(30),t)=0 or Search(Chr(31),t)=0)
     Then    
          Grava("")

          nlb=nlb+1
          
          nf="?"
          For i From 1 To pw
        
           If FieldInfo()<>nf
              Then 
                   If i>1 Then GravaCampo() EndIf
   
                   s=""
                   nf =FieldInfo()
                   tpf="caption"
                   tf =""   
                   tm =0
                   nc =i
 
           Endif
           s=s+cursorchar()
        
           tm=tm+1
        
           Right
           
          EndFor
          
          Switch
            Case nf="": 
                 If STrim(s)<>"" 
                    Then s=rtrim(s)
                         tm=len(s)
                         GravaCampo() 
                 EndIf
            OtherWise : 
                 
                 
                 GravaCampo()
          EndSwitch   

  EndIf


  CtrlHome
  Down
  
  If rowno()=nl then quitLoop endif
EndWhile


Do_It!
setdir "\\sistemas\\cadastro"


ClearAll
Release Vars All
Release Procs All
 
