Formatowanie i wstawianie znakow w txt

0

Witam,
Zaczynam swoja przygode z Delphi 7, i mam problem, ktory dla wielu z was jest przebanalny...
mianowicie czy jest mozliwosc w powyzszym jezyku napisianie programu ktorego zadaniem bedzie poprzez wczytanie przez opendialog pliku txt przekonwertowanie go w inna forme i zapisanie (takze w txt)?
Np:
Plik przed konwersja:
aaaaa bbbbb cccccc dddddd eeeeee ffffffff
aaaaa bbbbbbb ccccccccc dddddddd eeeeeee fffffffff

Plik po konwersji:
aaaaa;bbbbb;cccccc;dddddd;eeeeee;fffffffff
aaaaa;bbbbbbb;ccccccccc;dddddddddd;fffffffffff

dziekuje

0

With TStrnigList.Create do
Begin
LoadFromFile(ścieżka);
Text := StringReplace(Text, ' ', ' ', [rfReplaceAll]);
Text := StringReplace(Text, ' ', ';', [rfReplaceAll]);
SaveToFile(ścieżka);
Free;
End;

0

Dzieki wielkie, kombinuje ale dalej nie bardzo wiem jak to zrobic... Czy zrobic to w formie z 3 buttonami (Otworz, konwertuj i zapisz)? czy wszyskto pojdzie z automatu?. Kiedy wpisuje powyzszy kod zawsze cos nie chce dzialac :(

0

Prosze o poprawki

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var Text:TStringList;

begin
Text := TStringList.Create;
Text.LoadFromFile('C:\Documents and Settings\lista.txt');
Text := StringReplace(Text, ' ', ' ', [rfReplaceAll]);
Text := StringReplace(Text, ' ', ';', [rfReplaceAll]);
SaveToFile('C:\Documents and Settings\lista.txt');
Text.Free;
End;
end;

end.

0

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var T:TStringList;

begin
T := TStringList.Create;
T.LoadFromFile('C:\Documents and Settings\lista.txt');
T.Text := StringReplace(T.Text, ' ', ' ', [rfReplaceAll]);
T.Text := StringReplace(T.Text, ' ', ';', [rfReplaceAll]);
T.SaveToFile('C:\Documents and Settings\lista.txt');
T.Free;
end;

end.

1 użytkowników online, w tym zalogowanych: 0, gości: 1