Ver Mensaje Individual
  #1  
Antiguo 08-04-2015
doctorhd doctorhd is offline
Miembro
NULL
 
Registrado: abr 2013
Posts: 48
Reputación: 0
doctorhd Va por buen camino
set no funciona

Hola a todos, tengo el siguiente código:
Código Delphi [-]

TEnumTypeData = (tyNone,tyCurrency, tyBoolean, tyDate, tyDateTime, tyFloat, tyInteger, tyString, tyExpandString, tyTime, tyBinaryData);

TClaveValor = record
      private
        FClave:string;
        FValueDefault:Variant;
        FValue:Variant;
        FTipo:TEnumTypeData;
        procedure SetClave(const Value:string);
        procedure SetValueDefault(const Value:variant);
        procedure SetValue(const Value:variant);
        procedure SetTipo(const Value:TEnumTypeData);
      public
        property Clave: string read FClave write SetClave;
        property ValueDefault: Variant read FValueDefault write SetValueDefault;
        property Value:Variant read FValue write SetValue;
        property Tipo: TEnumTypeData read FTipo write SetTipo;
    end;

  procedure TClaveValor.SetClave(const Value:string);
  begin
    FClave:=Value;
  end;

  procedure TClaveValor.SetValueDefault(const Value:variant);
  begin
    FValueDefault:=Value;
  end;

  procedure TClaveValor.SetValue(const Value:variant);
  begin
    FValue:=Value;
  end;

  procedure TClaveValor.SetTipo(const Value:TEnumTypeData);
  begin
    FTipo:=Value;
  end;

  type
    TArrayClaveValor = array of TClaveValor;


  type
    TConfigBDRegistro = class
    private
      FTipoServer:TClaveValor;
      FNameServer:TClaveValor;
      FRuta:TClaveValor;
      FProComunicacion:TClaveValor;
      FVendorLib:TClaveValor;
      FListCampos:TArrayClaveValor;
      procedure setListCamposBD(value:TArrayClaveValor);
      function getListCamposBD:TArrayClaveValor;
    public
      constructor Create;
      property TipoServer:TClaveValor read FTipoServer write FTipoServer;
      property NameServer:TClaveValor read FNameServer write FNameServer;
      property Ruta:TClaveValor read FRuta write FRuta;
      property ProComunicacion:TClaveValor read FProComunicacion write FProComunicacion;
      property VendorLib:TClaveValor read FVendorLib write FVendorLib;
      property ListCampos:TArrayClaveValor read getListCamposBD write setListCamposBD;
    end;

  constructor TConfigBDRegistro.Create;
  begin
    Setlength(FListCampos,5);{Dimencionamos el tamaño de la lista de campos}
  end;{constructor}

  procedure TConfigBDRegistro.setListCamposBD(Value:TArrayClaveValor);
  begin
    FTipoServer:=Value[0];
    FNameServer:=Value[1];
    FRuta:=Value[2];
    FProComunicacion:=Value[3];
    FVendorLib:=Value[4];
  end;{function}

  function TConfigBDRegistro.getListCamposBD:TArrayClaveValor;
  begin
    FListCampos[0]:=FTipoServer;
    FListCampos[1]:=FNameServer;
    FListCampos[2]:=FRuta;
    FListCampos[3]:=FProComunicacion;
    FListCampos[4]:=FVendorLib;
    result:=FListCampos;
  end;{function}

La clase almacena ciertos parámetros de conexión para una BD, el tema es que necesito recorrer los campos de la clase en un bucle, por esto implemento el campo FListCampos, que es un array de TClaveValor, el problema se suscita al asignar valores a los campos a través del array. Nunca ingresa al prodedure setListCamposBD, que es el encargado de asignar lo valores, la llamada que se realiza es la siguiente:

Código Delphi [-]
   ....
   vInicio:=Low(ListCampos);
   vFin:=High(ListCampos);
   {recorremos la lista de campos}
   for vIndice:=vInicio to vFin do begin
     ListCampos[vIndice].Value:='un Dato';{esta asignación no tiene efecto en el campo que se accede a través del array}
   end;{for}
  ....

Gracias de antemano por su ayuda.
Saludos...
Responder Con Cita