The declaration of the type is:

type
  TMediaLibrary = record
    Title:string[30];
    TrackNo:integer;
    Artist:string[30];
    Album:string[30];
    Year:string[4];
    Genre:string[30];
    Comment:String[30];
    Directory:string;
  end; 

var  SongInfo: TMediaLibrary;

and the file implementation of it is here:

procedure TForm1.Button1Click(Sender: TObject);
var
  SongFile:string;
  MediaLibrary: file of TMediaLibrary; <<<Error is here
begin
.
.
.
.
  AssignFile(MediaLibrary, 'C:\Program Files\toMedia Player\data\libr.db');
  rewrite(MediaLibrary);
  Write(MediaLibrary, SongInfo);
  CloseFile(MediaLibrary);
end;

My problem is that when i try to compile the code it gives the error "Type TMediaLibrary needs finalization - not allowed in file type". This is my first post on any coding community site as most problems have already been solved already, but this has stumped me and google.

Thanks alot for any help.

Recommended Answers

All 2 Replies

The string (Directory) in the record is causing your problem. You'll need to change it to e.g. string[30]. string may not appear in a typed file, since it's length is undetermined.

Thanks a lot that sorted it.

Tom

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.