In Delphi I have the following classes:
type
TSong = class(TObject)
private
FArtist: String;
FTitle: String;
procedure SetArtist(Artist: String);
procedure SetTitle(Title: String);
public
property Artist: String read FArtist Write SetArtist;
property Title: String read FTitle Write SetTitle;
constructor Create(Artist, Title: String);
end;
type
TPlaylist = class(TList)
private
procedure ShowInListBox(Box: Pointer);
public
{ Public-Deklarationen }
end;
At runtime, I create instances of these classes:
Playlist := TPlaylist.Create;
Playlist.Add(TSong.Create('Artist 1', 'Title 1'));
Playlist.Add(TSong.Create('Artist 2', 'Title 2'));
Playlist.Add(TSong.Create('Artist 3', 'Title 3'));
Playlist.Add(TSong.Create('Artist 4', 'Title 4'));
When the program is closed, I would like to save these data into a text file. How can I do this?
The best way would probably be to create a procedure which belongs to the TPlaylist class, right?
procedure SaveToTxtFile(fName: String);
What should such a function exactly do? When the program is started again, I would like to be able to build the playlist again.
It would be nice if the data would be saved in a text file like this:
Artist 1///Title 1
Artist 2///Title 2