The code below is doing exactly what I need it too, however it takes over 5 min to complete the job.
For example I have over 2000 lines in a text file. Each line
looks similar to the following:
$PG92NVU3 PG92NVU3
$P8M00Q76 8M00Q76
$PVCSYQVT VCSYQVT
$PNSFGBJZ NSFGBJZ
$PDNTHV7G DNTHV7G
$PM7S2SL2 M7S2SL2
$P9W4JR8M 9W4JR8M
$PHL2T3GD HL2T3GD
$PZZX4QTA ZZX4QTA
The changes to the new file would look like the following:
*$PG92NVU3* PG92NVU3
*$P8M00Q76* 8M00Q76
*$PVCSYQVT* VCSYQVT
*$PNSFGBJZ* NSFGBJZ
*$PDNTHV7G* DNTHV7G
*$PM7S2SL2* M7S2SL2
*$P9W4JR8M* 9W4JR8M
*$PHL2T3GD* HL2T3GD
*$PZZX4QTA* ZZX4QTA
As I said the below code works, the issue is its taking forever
to make the needed changes.
Any ideas ?
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
x: Integer;
Target: String;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
memo1.Lines.LoadFromFile('C:\Users\CCW\Desktop\BCD.ppc');
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
application.ProcessMessages;
For x := 0 to memo1.Lines.Count -1 do
begin
Target := Copy(memo1.Lines[x],1,Length(Memo1.Lines[x]));
Insert('*',Target,1);
Insert('*',Target,11);
Memo1.lines.Strings[x] := Target;
//label1.Caption := Target;
end;
memo1.Lines.SaveToFile('C:\Users\CCW\Desktop\BCD-Ready.ppc');
end;
end.