Ver Mensaje Individual
  #7  
Antiguo 30-09-2005
[maeyanes] maeyanes is offline
Capo de los Capos
 
Registrado: may 2003
Ubicación: Campeche, México
Posts: 2.732
Reputación: 26
maeyanes Va por buen camino
Cita:
Empezado por lucasarts_18
Hola:

maeyanes, gracias resulto de maravilla, ya no se cae..
No quedo igual como lo expusiste tú ya que tendría que haber cambiado algunas cosas, pero lo acomodé a lo lógica del programa y está funcionando bien..

Nuevamente gracias..

Saludos
Que bueno que te sirvió así...

Cita:
Empezado por lucasarts_18
PD: No está malo saber porque de la otra forma se caía..
Buscando en google encontré esto: http://www.faqts.com/knowledge_base/...html/aid/24059

Aquí lo reproduzco:
Código Delphi [-]
{ Delphi: File: Error: I/O Error 103

Cause:
A file is assigned and then closed, but the file pointer has not
(for all possible cases) been reset or rewritten, in between.

---

Solution:
Reset or rewrite the file pointer in all possible cases.

---

The source code with the problem looks like this: }
procedure TForm1.PROCFileCreateNew( filenameS : string );
var fP : TextFile;
begin
 AssignFile( fP, filenameS );
 if FNFileCheckExistNotB( filenameS ) then begin
  Reset( fP );
 end;
 Close( fP );
end;

// Then the error occurs in Close( fP );

{---

Solution:
You should in any case reset the file pointer (using 'reset'
or 'rewrite') between you 'assigned' the file until it reaches the
'close'.

E.g. like this: }
procedure TForm1.PROCFileCreateNew( filenameS : string );
var fP : TextFile;
begin
 AssignFile( fP, filenameS );
 //
 // so you also cover all other possibilities
 // (like also in the other branch of the 'if')
 // between assign and close
 // by putting or a reset or a rewrite there
 //
 if FNFileCheckExistNotB( filenameS ) then begin
  Rewrite( fP );
 end
 else begin
  Reset( fP );
 end;
 Close( fP );
end;

Espero que esto te de una idea de por que el error en el código original.


Saludos...
Responder Con Cita