lionelhill
Technical User
Just a question that's more of historical interest than anything else, but I'd be very interested if anyone knows:
Why is it that in Turbo Pascal 6.0 you cannot give the value of one file variable to another:
var
a : file;
b : file;
begin
assign(a, 'myfile.ext');
...
a := b; {Not Allowed! }
...
But you can embed a file in a record, and assign the whole record, and then it works as expected (therefore it is physically possible):
type
MyRec = record
thing : file;
end;
var
a : MyRec;
b : MyRec;
begin
assign(a.thing, 'myfile.ext');
b := a;
reset(b.thing, 1; {works fine!}
....
I'm intrigued why the writers of TP felt a file should not be treated like any other variable.
Why is it that in Turbo Pascal 6.0 you cannot give the value of one file variable to another:
var
a : file;
b : file;
begin
assign(a, 'myfile.ext');
...
a := b; {Not Allowed! }
...
But you can embed a file in a record, and assign the whole record, and then it works as expected (therefore it is physically possible):
type
MyRec = record
thing : file;
end;
var
a : MyRec;
b : MyRec;
begin
assign(a.thing, 'myfile.ext');
b := a;
reset(b.thing, 1; {works fine!}
....
I'm intrigued why the writers of TP felt a file should not be treated like any other variable.