mam problem z posortowaniem zawartości pliku w kolejności alfabetycznej. W pliku znajdują się same pojedyncze litery.
Podczas odpalenia programu dostaje błąd: Access violation at address 004045A0 in module 'sort_alfabet.exe'. Read of address 0000000E
Ponieważ zaczynam dopiero programowanie nie bardzo wiem co to może oznaczać
Proszę o pomoc
Poniżej kod
unit alfabetyczne;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
Tz_pliku = class(TForm)
Memo1: TMemo;
pobierz: TButton;
Memo2: TMemo;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
save: TButton;
Edit2: TEdit;
Edit3: TEdit;
procedure pobierzClick(Sender: TObject);
procedure saveClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
z_pliku: Tz_pliku;
implementation
{$R *.dfm}
procedure Tz_pliku.pobierzClick(Sender: TObject);
var
k,j,i,x,n,h,g,y,m: integer ;
a,e: string;
tab:array of string;
begin
Memo1.Lines.Clear;
Memo2.Lines.Clear;
a:=edit1.Text;
Memo1.Lines.Add(a);
Memo1.Lines.LoadFromFile(a);
Memo1.Lines.Count;
n:=Memo1.Lines.Count ;
SetLength(tab, n);
x:=0;
y:=0;
for m:=0 to n-1 do
begin
tab[y]:= Memo1.Lines[x];
y:=y+1;
x:=x+1;
end;
for i:=0 to x-1 do
for j:=0 to x-1 do
if AnsiCompareText(tab[j],tab[j+1])>0 then
begin
e := tab[j];
tab[j] := tab[j+1];
tab[j+1] := e;
end;
h:=0 ;
for g:=0 to x-1 do
begin
Memo2.Lines.Add(tab[h]);
h:=h+1;
end;
end;
procedure Tz_pliku.saveClick(Sender: TObject);
var
TF : TextFile;
i : Integer;
b: string;
begin
b:=Edit2.Text;
AssignFile(TF, b);
try
Rewrite(TF);
for I := 0 to Memo2.Lines.Count do
begin
Writeln(TF, Memo2.Lines[i]);
end;
Edit3.Text:=('zapisano dane');
finally
CloseFile(TF);
end;
end;
end.