Ler arquivo e separar dados
Boa tarde,
alguem poderia me ajudar a concluir esse codigo?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, Unit2;
type
TForm1 = class(TForm)
ListBox1: TListBox;
BitBtn1: TBitBtn;
ListBox2: TListBox;
BitBtn2: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
thread : TMinhaThread;
I: Integer;
linha: String;
Arq: TextFile;
implementation
{$R *.dfm}
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
thread := TMinhaThread.Create(false);
thread.Interval := StrToInt('100');
end;
procedure TForm1.BitBtn2Click(Sender: TObject);begin
AssignFile (arq, GetCurrentDir()+'/ps.hack');
Reset (arq);
while not Eof (arq) do
begin
ReadLn (arq, linha);
ListBox1.Items.Add(linha);
if (linha = '#Outros#') then
ReadLn (arq, linha);
ListBox2.Items.Add(linha);
end;
CloseFile(arq);
end;end.
No caso ele le o arquivo ps.hack que possui linhas como:
Teste1
Teste2
Teste3
#Outros#
Teste4
Teste5
Teste6
Quando ele chegar em #Outros# ele deve adicionar o resto no listbox2 e não adicionar o #Outros# em nenhum dos dois.
Se alguem puder me ajudar.
Grato,
Douglas Pontes.
Discussão (3)
Carregando comentários...