RAD Studio (Common)
ContentsIndex
PreviousUpNext
E2024: Invalid function result type (Delphi)

File types are not allowed as function result types.

program Produce;

function OpenFile(Name: string): File;
begin
end;

begin
end.

You cannot return a file from a function.

program Solve;

procedure OpenFile(Name: string; var F: File);
begin
end;

begin
end.

You can 'return' the file as a variable parameter. Alternatively, you can also allocate a file dynamically and return a pointer to it.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!