Board index » delphi » open a new file gives error incompatible types

open a new file gives error incompatible types

procedure TmainChangery.FileSaveAs(Sender: TObject);
var current   : System.Text;
    filename  : String[80];
begin
  if SaveDialog.Execute then
  begin
       filename := SaveDialog.Filename;
       Assign(current, filename);
       Rewrite(current);
       currentset.Caption := filename;
  end;
end;

Incompatible types Tpersistent and Text.

Can someone please tell me what is wrong about this assign statement.

Please Mail the answer to Marteijn_Nouw...@thepentagon.com

Thanks,

Marteijn.

 

Re:open a new file gives error incompatible types


On 9 Dec 1996 22:33:06 GMT, "CloudDancer"

Quote
<CloudDan...@thepentagon.com> wrote:
>procedure TmainChangery.FileSaveAs(Sender: TObject);
>var current   : System.Text;
>    filename  : String[80];
>begin
>  if SaveDialog.Execute then
>  begin
>       filename := SaveDialog.Filename;
>       Assign(current, filename);
>       Rewrite(current);
>       currentset.Caption := filename;
>  end;
>end;

>Incompatible types Tpersistent and Text.

>Can someone please tell me what is wrong about this assign statement.

>Please Mail the answer to Marteijn_Nouw...@thepentagon.com

You used "System.Text" but you didn't prefix Assign with "System.".
A better way is to use "textfile" as your file type and AssignFile and
CloseFile for accessing the file.

"thepentagon.com"?

Cheers

--
Brad Choate <cho...@cswnet.com>  | http://www.cswnet.com/~choate
Webmaster of The Delphi EXchange | http://www.DelphiEXchange.com
Have a Coke and a :)

Re:open a new file gives error incompatible types


On 9 Dec 1996 22:33:06 GMT, "CloudDancer"

Quote
<CloudDan...@thepentagon.com> wrote:
>procedure TmainChangery.FileSaveAs(Sender: TObject);
>var current   : System.Text;
>    filename  : String[80];
>begin
>  if SaveDialog.Execute then
>  begin
>       filename := SaveDialog.Filename;
>       Assign(current, filename);

AssignFile(current, filename);

Quote
>       Rewrite(current);
>       currentset.Caption := filename;
>  end;
>end;

--
Ray Lischner, Tempest Software, Inc., Corvallis, Oregon, USA
Author of Secrets of Delphi 2 (http://www.tempest-sw.com/secrets/)

Other Threads