Witam, głowie się juz od kilku godzin z taka procedura zapisu do pliku struktury:
type
artists=^artist;
albums=^album;
songs=^song;
artist=record
title:string;
//id:integer;
next:artists;
end;
album=record
title:string;
artist:artists;
sizeA:integer;
sizes:integer;
song:songs;
next:albums;
end;
song=record
title:string;
feature:artists;
size:integer;
next:songs;
end;
procedure save(var AlbumH:albums;name:string);
var basealbums:file of albums;
baseartists:file of artists;
basefeatures:file of artists;
basesongs:file of songs;
temp,tail:albums;
temp1,tail1,temp5:artists;
temp2,tail2:songs;
ArtistSize,FeaturesSize,SongsSize:integer;
begin
assign(basealbums,name+'albums');
assign(basesongs,name+'songs');
assign(baseartists,name+'artists');
assign(basefeatures,name+'artists');
//writeln('Podaj nazwe bazy, umieszczonej w tym samym folderze);
rewrite(baseartists);
close(baseartists);
//IF IOResult<>0 then writeln('Baza o taki nazwie nie moze zostac odczyta, wpisz poprawna nazwe');
rewrite(basealbums);
//IF IOResult<>0 then writeln('Baza o taki nazwie nie moze zostac odczyta, wpisz poprawna nazwe');
rewrite(basesongs);
//IF IOResult<>0 then writeln('Baza o taki nazwie nie moze zostac odczyta, wpisz poprawna nazwe');
rewrite(basefeatures);
//IF IOResult<>0 then writeln('Baza o taki nazwie nie moze zostac odczyta, wpisz poprawna nazwe');
close(basefeatures);
writeln('test');
ArtistSize:=0;
writeln(ArtistSize);
while(AlbumH<>nil) do
begin
while(AlbumH^.artist<>nil) do
begin
ArtistSize:=1+ArtistSize;
reset(baseartists);
seek(baseartists,FileSize(baseartists));
writeln(FileSize(baseartists));
write(baseartists,AlbumH^.artist);
temp1:=AlbumH^.artist^.next;
dispose(AlbumH^.artist);
AlbumH^.artist:=temp1;
//writeln(AlbumH^.artist^.title);
readln;
close(baseartists);
end;
SongsSize:=0;
while(AlbumH^.song<>nil) do
begin
SongsSize:=1+SongsSize;
FeaturesSize:=0;
//AlbumH^.song:=AlbumH^.song^.next;
while (AlbumH^.song^.feature<>nil) do
begin
FeaturesSize:=FeaturesSize+1;
reset(basefeatures);
seek(basefeatures,FileSize(basefeatures));
write(basefeatures,AlbumH^.song^.feature);
temp1:=AlbumH^.song^.feature^.next;
dispose(AlbumH^.song^.feature);
AlbumH^.song^.feature:=temp1;
close(basefeatures);
end;
AlbumH^.song^.size:=FeaturesSize;
write(basesongs,AlbumH^.song);
temp2:=AlbumH^.song^.next;
dispose(AlbumH^.song);
AlbumH^.song:=temp2;
end;
AlbumH^.sizeA:=ArtistSize;
AlbumH^.sizeS:=SongsSize;
write(basealbums,AlbumH);
temp:=AlbumH^.next;
dispose(AlbumH);
AlbumH:=temp;
end;
close(basealbums);
close(basesongs);
//KONIEC
//SPRAWDZENIE(TUTAJ WYRZUCA PUSTE ODPOWEIDZI,zapisywane elemnty istnieja, i sa usuwane z pamięci);
reset(baseartists);
seek(baseartists,1);
close(basealbums);
reset(basealbums);
seek(basealbums,1);
new(temp);
read(basealbums,temp);
writeln(temp^.title,'NIEMA?');
readln;
close(baseartists);
close(basealbums);
close(basesongs);
end;
Procedura poprawnie usuwa pamięć, jednak do plików, nie jest nic zapisywane, co sprawdzałem sobie nawet wewnątrz, tej samej procedury.
Procedura nie wyrzuca bledow, i porpawnei czysci pamięć o czym wspomniałem wyżej, wiec dobrze porusza się po zapisywanej strukturze.
Dzięki bardzo za jaką kolwiek pomoc.