E2024 Invalid function result type (Delphi)
Go Up to Error and Warning Messages (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.