Mark,
Your variable FIleName is a handle.
So your code should look like this:
Var
FileName, FileOne, FileTwo : TextFile;
FileName, FileOne, FileTwo : TextFile;
File :
String;
begin
if cond1 then
File := 'FileOne.txt';
begin
if cond1 then
File := 'FileOne.txt';
else
File := 'FileTwo.txt';
File := 'FileTwo.txt';
AssignFile(FileName, File);
Rewrite(FileName);
Write(FileName,
'Data', 'MoreData');
end;
end;
Have
fun,
Damien
Long
[EMAIL PROTECTED]
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Mark Howard
Sent: Friday, 9 March 2001 12:33 PM
To: Multiple recipients of list delphi
Subject: Re: [DUG]: Referencing variable TextFile names
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Mark Howard
Sent: Friday, 9 March 2001 12:33 PM
To: Multiple recipients of list delphi
Subject: Re: [DUG]: Referencing variable TextFile names
In fact, to state it again - more clearly this time. I'm sorry for the earlier muddle.I want to be able to do something like the following:Var
FileName, FileOne, FileTwo : TextFile;File : String;
begin
if cond1 then
begin
FileName := FileOne;
File := 'FileOne.txt';
end
else
begin
FileName := FileTwo;
File := 'FileTwo.txt';
end;
AssignFile(FileName, File);Rewrite(FileName);Write(FileName, 'Data', 'MoreData');
end;
But I can't go
FileName := FileOne;I get this error message "Operator not applicable to this operand type"
That's the problem. I'm sure it's very basic - I've just never had to do it
before and can't think where else to look in the Help files.
Mark