Hola tiqui_loquito.
Si no te entendí mal, te hago esta propuesta:
Código Delphi
[-]
...
implementation
var
IdCe: TStrings;
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] + ' ' +
IntToStr(Integer(IdCe.Objects[i])) );
end;
procedure TForm1.btnDemoClick(Sender: TObject);
begin
AgregarCausa('11111','0'); MostrarDatos(ListBox1.Items); ListBox1.Items.Add('------------------------');
ModificarCausa('11111','11'); MostrarDatos(ListBox1.Items); BorrarCausa('11111'); ...
end;
Saludos