Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi progressbar in einleseroutine läuft zu schnell (https://www.delphipraxis.net/24346-progressbar-einleseroutine-laeuft-zu-schnell.html)

Michael80 19. Jun 2004 16:20


progressbar in einleseroutine läuft zu schnell
 
So hab folgende Einleseroutine und will da nun die progressbar integrieren die da
über ndx gesteuert wird.

ich weiß warum sie zu schnell läuft, kanns aber net ändern ... sobald ndx bei 100 is, is die
die pg voll aber es läuft noch weiter.

was kann ich jetzt machen, das sich das an die dateigröße anpasst?

Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
  masterSL : TStringList;
  detailSL : TStringList;
  ndx     : Integer; // Laufvariable für Master
  begin
  masterSL := TStringList.Create; // Master StringList
  detailSL := TStringList.Create; // Detail StringList
  try
    detailSL.Delimiter := ';';  // Trennzeichen der Einträge pro Zeile
    detailSL.QuoteChar := '"';  // Quoting Zeichen.
    masterSL.LoadFromFile('C:\KUNDENSTAMM.txt');
    for ndx := 0 to Pred (mastersl.Count) do
    begin
      progressbar1.Position := ndx; //<------------------------------------------
      detailsl.Clear;
      detailsl.DelimitedText := '"' + StringReplace(mastersl.Strings[ndx],';','";"',[rfReplaceAll]);
      //detailsl.savetofile('c:\test.txt');
      while detailsl.Count < 11 do detailsl.Add('');
      with IBQuery1 do
      begin
        Close;
        SQL.Text := 'INSERT INTO KUNDENSTAMM(KDNR, ANREDE, VORNAME, NACHNAME, ZUSATZ, STRASSE,ORTSTEIL,PLZ,ORT,TELEFON,TELEFAX) VALUES (:wert1,:wert2,:wert3,:wert4,:wert5,:wert6,:wert7,:wert8,:wert9,:wert10,:wert11)';
        ParamCheck := True;
        ParamByName('wert1').AsInteger := strtoint(detailsl.Strings[0]);
        ParamByName('wert2').AsString := detailsl.Strings[1];
        ParamByName('wert3').AsString := detailsl.Strings[2];
        ParamByName('wert4').AsString := detailsl.Strings[3];
        ParamByName('wert5').AsString := detailsl.Strings[4];
        ParamByName('wert6').AsString := detailsl.Strings[5];
        ParamByName('wert7').AsString := detailsl.Strings[6];
        ParamByName('wert8').AsString := detailsl.Strings[7];
        ParamByName('wert9').AsString := detailsl.Strings[8];
        ParamByName('wert10').AsString := detailsl.Strings[9];
        ParamByName('wert11').AsString := detailsl.Strings[10];
        ExecSQL;
        end;
        IBTransaction1.Commit;
    end;
  finally
    FreeAndNil (mastersl);
    FreeAndNil (detailsl);
  end;
end;

theomega 19. Jun 2004 16:25

Re: progressbar in einleseroutine läuft zu schnell
 
ich glaube du solltest progressbar1.max auf die anzahl der Linien setzten!

SirThornberry 19. Jun 2004 16:26

Re: progressbar in einleseroutine läuft zu schnell
 
einfach:
Delphi-Quellcode:
[...]
Progressbar.Max := masters.Count; //<------------------------------------------
for ndx := 0 to Pred (mastersl.Count) do
begin
  progressbar1.Position := ndx;
[...]

Michael80 19. Jun 2004 16:28

Re: progressbar in einleseroutine läuft zu schnell
 
perfekt :thuimb:


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:49 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz