Ver Mensaje Individual
  #5  
Antiguo 21-03-2007
soivago soivago is offline
Registrado
 
Registrado: abr 2006
Posts: 6
Reputación: 0
soivago Va por buen camino
Smile Perfecto solucionado!!!!

Te comento que funciono, y que si le colocas implementation da error al compilar dice que falta un punto (.)

aca te muestro mas o menos como quedo el programa...
lo que hace es enviar un mensaje , y con el evento que creamos cuando recibe una respuesta la escribe en un archivo
lo que esta en rojo es lo que me daba problemas y ahora funciona,
MUCHAS GRACIAS!!!




Código Delphi [-]
program ActualizaHoraMD400_Console;

{$APPTYPE CONSOLE}

uses
// *********Estas son las que usaba la version con UI
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, etc...

type
  TEvents = class
    class procedure IdLogEvent1ReceivedNEW(ASender: TComponent; const AText, AData: String);
  end;

//implementation

var
//**********  Aca van los componentes
    TcpClient1: TIdTCPClient;
    IdLogEvent1: TIdLogEvent;
//**********

  Relojes : array of TReloj;
  archLog : String;
  cuanto : integer;
  const Const_Un_Minuto : Real = 0.00069445;                  //    = 1 minuto
FUNCTION Loguear(mensaje : String; archivoLog : String = sys_directorio + 'archivo.log') : Boolean;
var
Arch : TextFile;
begin
try
 result := TRUE;
try
   AssignFile(Arch, archivoLog);
   if NOT FileExists(archivoLog) then        // NO existe un archivo de log
      Rewrite(Arch)                          // Crea Archivo log
       else
      Append(Arch);                          // SI ya existe lo abre para agregar datos
    finally
    Writeln(Arch, mensaje);                  // escribe en el archivo
    Flush(Arch);                             // vacia el buffer del archivo texto
    CloseFile(Arch);                         // lo cierra de nuevo
    end;
    except
     Result := FALSE;
    end;
end;
Class PROCEDURE TEvents.IdLogEvent1ReceivedNEW(ASender: TComponent; const AText, AData: String);
begin
Loguear(AText + ' Respuesta de ' + TIdTCPClient(IdLogEvent1.Connection).Host + ' >> ' + Adata, archLog);
TcpClient1.Disconnect;
end;
PROCEDURE ActualizaDatosPC();
begin
 try
 IdLogEvent1 := TIdLogEvent.Create(nil);
 TcpClient1 := TIdTCPClient.Create(nil);
      try
        IdLogEvent1.OnReceived := TEvents.IdLogEvent1ReceivedNEW;
        IdLogEvent1.Active := TRUE;
        TcpClient1.Intercept := IdLogEvent1;
        TcpClient1.BoundIP := '172.23.8.4'; //GStack.LocalAddress;
        TcpClient1.BoundPort := 0;
        TcpClient1.ReadTimeout := int_TimeOut;
      except
        Loguear('Error al obtener el IP Local', archLog);
        raise
      end;
 except
   Loguear('Error al obtener el IP Local', archLog);
   raise;
 end;
end;
Responder Con Cita