Delphi – E2002 File type not allowed here

File types are not permitted as value arguments or as the file type’s base type. They can’t be used as function return types, and you can’t assign them; nevertheless, those mistakes will result in a different error message.

program Produce;

procedure WriteInteger(T: Text; I: Integer);
begin
  Writeln(T, I);
end;

begin
end.

The issue is that T is a value argument of type Text, which is a file type in this case. Remember that whatever you write to a value parameter has no effect on the caller’s copy of the variable, thus designating a file as a value parameter is a waste of time.

program Solve;

procedure WriteInteger(var T: Text; I: Integer);
begin
  Writeln(T, I);
end;

begin
end.

The difficulty is solved by declaring the parameter as a var parameter.