German C. Basisty ?????:

Now I really dont know whats wrong, please help me.

The writting code:

========================================

procedure TForm1.Button1Click(Sender: TObject);

var

  archivo: File of String;

  cadena: String;

begin

  cadena := Edit1.Text;

  ShowMessage(cadena);

  System.Assign(archivo, 'archivo.dat');

  System.Rewrite(archivo);

  Write(archivo, cadena);

  System.Close(archivo);

end;

========================================

The Reading code (Another app):

========================================

procedure TForm1.Button1Click(Sender: TObject);

var

  archivo: file of string;

  cadena: string;

begin

  System.Assign(archivo, 'archivo.dat');

  System.Reset(archivo);

  read(archivo, cadena);

  System.Close(archivo);

  Edit1.Text := cadena;

end;
========================================

When I run the writting app, it seems to work, the archivo.dat file is created. But when I run the Reading app, and press the read button, it apperas an error message who say something about Access violation.

Please help! Have mercy!!!!

Regards,

German

The idea is to change the type of your file to  Text; I.e.


========================================

procedure TForm1.Button1Click(Sender: TObject);

var

 archivo: Text;

 cadena: String;



begin

 cadena := Edit1.Text;

 ShowMessage(cadena);

 System.Assign(archivo, 'archivo.dat');

 System.Rewrite(archivo);

 Write(archivo, cadena);

 System.Close(archivo);

end;

========================================



The Reading code (Another app):



========================================

procedure TForm1.Button1Click(Sender: TObject);

var

 archivo: Text;

 cadena: string;



begin

 System.Assign(archivo, 'archivo.dat');

 System.Reset(archivo);

 read(archivo, cadena);

 System.Close(archivo);



 Edit1.Text := cadena;



end;
========================================

Also, the good idea is to check the file existence before open it with FileExists() function.

*Regards, Alexey.*

Reply via email to