Agrega este metodo, para crear un log a un fichero que se llame igual que la aplicación, pero con extensión .log
Ten en cuenta que agregará (Append) lineas. Deberás borrarlo cada vez que lo ejecutes.
Código Delphi
[-]
procedure TForm1.Log(s: string);
var
F : TextFile;
FileName : string;
begin
FileName := ChangeFileExt(Application.ExeName, '.log');
AssignFile(F, FileName);
try
Append(F);
except
try
Rewrite(F);
except
on e: Exception do
ShowMessage('Error al abir fichero : ' + FileName + #13 + e.Message);
end;
end;
WriteLn(F, FormatDatetime('[yyyy-mm-dd hh:nn:ss.zzz] ', Now) + s);
CloseFile(F);
end;
Luego agrega llamadas a este metodo
Código Delphi
[-]
Log(Format('Inicio bucle. Lineas: %d', [DataGrid.RowCount]));
for i := 1 to (DataGrid.RowCount-1) do
begin
DataGrid.Row := i; Log(Format('Lineas: %d - %s', [i, DataGrid.cells[0,i]]));
If Trim(DataGrid.cells[0,i]) <> '' then
begin
If Trim(DataGrid.cells[0,i]) <> Trim(romp) then
begin
filaactual := DataGridagrupado.RowCount;
DataGridagrupado.Row := filaactual-1;
DataGridagrupado.Cells[0,filaactual] := DataGrid.Cells[0,i];
DataGridagrupado.Cells[1,filaactual] := DataGrid.Cells[1,i];
DataGridagrupado.Cells[2,filaactual] := FloatToStr(total);
total := 0;
total := total + StrToFloat(DataGrid.cells[2,i]);
romp := Trim(DataGrid.cells[0,i]);
DataGridagrupado.AddRow;
Log(Format(' Agrupado. Fila Actual: %d - %s', [filaactual, DataGridagrupado.Cells[0,filaactual]]));
end
else
begin
total := total + StrToFloat(DataGrid.cells[2,i]);
Log(Format(' Agrego a Total: %s', [DataGrid.cells[2,i]));
end;
end;
end;
Log(Format('Fin bucle'));
Supongo que verás que de alguna manera FilaActual se sale de control y toma un valor muy alto, creando esa cantidad de filas.