954,529 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

File of *Type*

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.

espSquall
Newbie Poster
10 posts since Sep 2008
Reputation Points: 10
Solved Threads: 1
 

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.

pritaeas
Posting Expert
Moderator
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 874
 

Thanks a lot that sorted it.

Tom

espSquall
Newbie Poster
10 posts since Sep 2008
Reputation Points: 10
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You