Prueba los siguiente (a ver si hay suerte)
Código Delphi
[-]
procedure TInventarios.Button2Click(Sender: TObject);
var
Archivo,Campos: TStringList;
I, J: Integer;
Codigo: string;
Cant : real;
Linea : Integer;
begin
Archivo:= TStringList.Create;
Campos:= TStringList.Create;
try
Archivo.LoadFromFile('C:\INVENTARIO.txt');
for I := 0 to Archivo.Count -1 do
begin
Codigo := '';
Cant := 0;
Campos.Clear;
Campos.CommaText:= Archivo[i];
if Campos.Count >= 2 then
begin
Codigo:= Campos[0];
Cant:= Strtofloat(Campos[1]);
end;
if (Codigo <> '') and (Cant > 0) then
begin
Linea:= Linea + 1;
DataModule1.STOMOV.Insert;
DataModule1.STOMOV.Fields[1].Value := 1;
DataModule1.STOMOV.Fields[3].Value := Linea;
DataModule1.STOMOV.Fields[4].Text := DateToStr(Now);
DataModule1.STOMOV.Fields[5].Value := 530;
DataModule1.STOMOV.Fields[7].Value := strToInt(Edit4.text);
DataModule1.STOMOV.Fields[8].Text := Codigo;
DataModule1.STOMOV.Fields[9].Value := Cant;
DataModule1.STOMOV.Post;
end;
end;
finally
Archivo.Free;
Campos.Free;
end;
end;
(Como verás, he respetado tu código original añadiéndole sólo unas sentencias)
Chao!