Prezados,
  
  estou criando uma rotina para criar um arquivo de texto, tá até aí td  
tranquilo, só q só está funcionando quando já existe o arquivo, criei  uma 
rotina para q se nao existisse o arquivo, o memso fosse criado, mas  ao criar o 
arquivo da um erro, doz q o arquivo jpa está sendo utilizado  por um outro 
processo.
  
  outra coisa, naum estou conseguindo ler o arquivo e jogá-lo em um list  box, 
faz algum tempo q naum me xo aom este componente qual seria a  sintaxe?
  
  Alguém poderia me ajudar com essa rotina?
  ficarei eternamente grato
  
  segue abaixo o fonto o qual está ocorrendo o erro:
  
  unit Ucontrole01;
  
  interface
  
  uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls;
  
  type
    TForm1 = class(TForm)
      edtmatricula: TEdit;
      edtaparelho: TEdit;
      edttelefone: TEdit;
      edtnome: TEdit;
      Label1: TLabel;
      Label2: TLabel;
      Label3: TLabel;
      Label4: TLabel;
      Button1: TButton;
      Button2: TButton;
      Button3: TButton;
      ListBox1: TListBox;
      procedure Button1Click(Sender: TObject);
      procedure Button3Click(Sender: TObject);
      procedure Button2Click(Sender: TObject);
  
    private
      { Private declarations }
    public
      { Public declarations }
  
    end;
  
  var
    Form1: TForm1;
  
  implementation
  
  {$R *.dfm}
  
  procedure limpacampos (Sender : TObject);
  begin
    with form1 do
      begin
        edtmatricula.clear;
        edtnome.clear;
        edtaparelho.clear;
        edttelefone.clear;
        edtmatricula.setfocus;
      end;
  end;
  
  
  procedure TForm1.Button1Click ( Sender : TObject );
  var
    existe : String;
    Arq, Arquivo : TStringList;
    Linha, LinhaGrava : String;
    x, cont : integer;
  begin
  
    if edtmatricula.text = '' then
      begin
        showmessage( 'Digite a Matricula do Agente' );
        edtmatricula.setfocus;
      end
      else
        if edtnome.text = '' then
          begin
            showmessage( 'Digite o Nome do Agente' );
            edtnome.setfocus;
          end
          else
            if edtaparelho.text = '' then
              begin
                showmessage( ' Digite o Código do Aparelho' );
                edtaparelho.setfocus;
              end
              else
                begin
                   existe := ( 'c:\' + ( formatdatetime( 'dd-mm-yy', now ) + 
'.txt'));
                  Arq := TStringList.Create;
                  Arquivo := TStringList.Create;
                  Linha := '';
                  LinhaGrava := '';
                  cont := 0;
                     if  not FileExists( existe ) then
                      begin
                         FileCreate( existe );
                         //LinhaGrava := ( edtmatricula.text + ',' + 
edtaparelho.text + ',' +  edttelefone.text + ',' + edtnome.text );
                         //Arquivo.Add( LinhaGrava );
                         //Arquivo.SaveToFile( existe );
                         //limpacampos( form1 );
                      end
                      else
                         //if FileExists( existe ) then
                           begin
                           Arq.LoadFromFile( existe );
                           For x := 0 to Arq.Count - 1 do
                             begin
                               Arquivo.Add(Arq.Strings[x]);
                               inc(cont);
                             end;
                             LinhaGrava := ( edtmatricula.text + ',' + 
edtaparelho.text + ',' +  edttelefone.text + ',' + edtnome.text );
                             Arquivo.Add( LinhaGrava );
                             Arquivo.SaveToFile( existe );
                             limpacampos( form1 );
  
                         end;
                end;
  end;
  
  
  
  procedure TForm1.Button3Click(Sender: TObject);
  begin
    close;
  end;
  
  procedure TForm1.Button2Click(Sender: TObject);
  begin
    limpacampos( form1 );
  end;
  
  
  end.
  
  
  
   
  

                
---------------------------------
 Yahoo! doce lar. Faça do Yahoo! sua homepage.

[As partes desta mensagem que não continham texto foram removidas]



-- 
<<<<< FAVOR REMOVER ESTA PARTE AO RESPONDER ESTA MENSAGEM >>>>>

<*> Para ver as mensagens antigas, acesse:
    http://br.groups.yahoo.com/group/delphi-br/messages

<*> Para falar com o moderador, envie um e-mail para:
    [EMAIL PROTECTED]
 
Links do Yahoo! Grupos

<*> Para visitar o site do seu grupo na web, acesse:
    http://br.groups.yahoo.com/group/delphi-br/

<*> Para sair deste grupo, envie um e-mail para:
    [EMAIL PROTECTED]

<*> O uso que você faz do Yahoo! Grupos está sujeito aos:
    http://br.yahoo.com/info/utos.html

 


Responder a