Ver Mensaje Individual
  #11  
Antiguo 25-02-2007
Avatar de nlsgarcia
[nlsgarcia] nlsgarcia is offline
Miembro Premium
 
Registrado: feb 2007
Ubicación: Caracas, Venezuela
Posts: 2.206
Reputación: 23
nlsgarcia Tiene un aura espectacularnlsgarcia Tiene un aura espectacular
2007-02-24-2 Respuesta a Roman

Hola:

Si modifico el programa como tu me sugieres, tendria algo como esto:

Código Delphi [-]
 
program TestFile;
 {$APPTYPE CONSOLE}
uses
  SysUtils, StrUtils;
Type
TPrnCmd = Record
   ProcPrnCmd : String[41];
   DatePrnCmd : String[13];
   TimePrnCmd : String[13];
   Status : String[31];
   CRLF : String[2];
end;
var
   i : integer;
   RegPrnCmd : TPrnCmd;
function LogPrnCmd(LogFile, ProcPrnCmd, StatusProc : String) : Boolean;
var
   i : integer;
   f: File of TPrnCmd;
   DateProc : String;
   AuxStr : String;
   CRLF : String;
begin
   LogFile := GetCurrentDir + '\' + LogFile;
   AssignFile(f, LogFile);
   FileMode := fmOpenWrite ;
   if FileExists(LogFile) then
      Reset(f)
   else
      Rewrite(f);
   DateProc := FormatDateTime('dd/mm/yyyy',Date);
   CRLF := Chr(13) + Chr(10);
   RegPrnCmd.ProcPrnCmd := ProcPrnCmd;
   RegPrnCmd.DatePrnCmd := MidStr(DateProc,7,4) + '-' + MidStr(DateProc,4,2) + '-' + MidStr(DateProc,1,2);
   RegPrnCmd.TimePrnCmd := FormatDateTime('hh:mm:ss',Time);
   RegPrnCmd.Status := StatusProc;
   RegPrnCmd.CRLF :=CRLF;
   Seek(f, FileSize(f));
   Write(f,RegPrnCmd);
   CloseFile(f);
end;
begin
   for i := 1 to 10 do
      LogPrnCmd('TestFile.txt','Proc'+IntToStr(i),'Status'+IntToStr(i));
end.

Y la salida obtenida seria esta:

Proc1 2007-02-24 19:50:11 Status1 
Proc2 2007-02-24 19:50:11 Status2 
Proc3 2007-02-24 19:50:11 Status3 
Proc4 2007-02-24 19:50:11 Status4 
Proc5 2007-02-24 19:50:11 Status5 
Proc6 2007-02-24 19:50:11 Status6 
Proc7 2007-02-24 19:50:11 Status7 
Proc8 2007-02-24 19:50:11 Status8 
Proc9 2007-02-24 19:50:11 Status9 
Proc10 2007-02-24 19:50:11 Status10 

Es por el caracter , que no use el tipo String.

Gracias nuevamente por tus comentarios.
Responder Con Cita