Ver Mensaje Individual
  #4  
Antiguo 07-03-2015
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola tiqui_loquito.

Si no te entendí mal, te hago esta propuesta:
Código Delphi [-]
...
implementation
var
  IdCe: TStrings; // almacena id y causa externa

procedure TForm1.FormCreate(Sender: TObject);
var
  TS: TStrings;
  i,p: Integer;
begin
  IdCe:= TStringList.Create;
  TS:= TStringList.Create;
  try
    TS.LoadFromFile('CausaExterna.txt');
    for i:= 0 to TS.Count-1 do
    begin
      p:= Pos(',',TS[i]);
      IdCe.AddObject(Copy(TS[i], 1, p - 1),
        TObject(StrToInt(Copy(TS[i], p + 1, MaxInt))));
    end;
  finally
    TS.Free;
  end;
end;

procedure AgregarCausa(const Id, Causa: string);
begin
  IdCe.AddObject(Id, TObject(StrToInt(Causa)));
end;

procedure ModificarCausa(const Id, Causa: string);
var
  ix: Integer;
begin
  ix:= IdCe.IndexOf(Id);
  if ix <> -1 then
    IdCe.Objects[ix]:= TObject(StrToInt(Causa));
end;

procedure BorrarCausa(const Id: string);
var
  ix: Integer;
begin
  ix:= IdCe.IndexOf(Id);
  if ix <> -1 then
    IdCe.Delete(ix);
end;

procedure MostrarDatos(TS: TStrings);
var
  i: Integer;
begin
  for i:= 0 to IdCe.Count-1 do
    TS.Add(IdCe[i] { ID } + ' ' +
           IntToStr(Integer(IdCe.Objects[i])) { causa externa});
end;

procedure TForm1.btnDemoClick(Sender: TObject);
begin
  AgregarCausa('11111','0');     // ejemplo agregar
  MostrarDatos(ListBox1.Items);  // mostrar
  ListBox1.Items.Add('------------------------');
  ModificarCausa('11111','11');  // ejemplo modificar
  MostrarDatos(ListBox1.Items);  // mostrar
  BorrarCausa('11111');          // ejemplo borrar
  ...
end;



Saludos
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....

Última edición por ecfisa fecha: 07-03-2015 a las 20:07:08.
Responder Con Cita