Thema: Delphi TList Schneller updaten

Einzelnen Beitrag anzeigen

tromorow
(Gast)

n/a Beiträge
 
#1

TList Schneller updaten

  Alt 19. Dez 2005, 20:11
Hi Läutz,
ich versuch hier jetzt noch mal Hilfe zu bekommen.
Ich hab ein Programm geschrieben mit einer TList.
Jetzt muss ich die Liste öfters nummerieren,
was wenn die Liste voll ist eine weile braucht.
Könnt Ihr mir helfen meine Funktion zu tunen?
Anbei ein Programmausschnitt und ein Beispiel des Listeninhalts.

Danke!
Gruß TT

Delphi-Quellcode:
procedure TSDIAppForm.UpdateList;
var
  regexpr : TRegExpr;
  i, j : Integer;
begin
  regexpr := TRegExpr.Create;
  List.Items.BeginUpdate;

    try

      i := 0;
      j := ini.ReadInteger('Number','Start',0);
      while (i <= List.Count-1) do
      begin
        if stx.ReadBool('Replace','Number',ini.ReadBool('System','Number',true)) then
        begin
          regexpr.Expression := stx.ReadString('Replace','NumSignRegExp',
                                  ini.ReadString('Number','SignRegExp','(?i)^N(\d+)\s*(.*)'));
          if (i = 0) and (stx.ReadBool('Replace','ID',ini.ReadBool('System','ID',true))) then
          begin
            regexpr.Exec(List.Items[i]);
            if OpenFileID = 0 then
              List.Items[i] := SysFuncs.SearchAndReplace(
                                 SysFuncs.SearchAndReplace(
                                   regexpr.Replace(
                                     List.Items[i],
                                     stx.ReadString('Replace','IDSign',
                                       ini.ReadString('ID','Sign','N$#')),
                                     true
                                   ),
                                   '$s',
                                   ' '
                                 ),
                                 '$#',
                                 IntToStr(List.Count-1)
                               )
            else
              List.Items[i] := SysFuncs.SearchAndReplace(
                                 SysFuncs.SearchAndReplace(
                                   regexpr.Replace(
                                     List.Items[i],
                                     stx.ReadString('Replace','IDSign',
                                       ini.ReadString('ID','Sign','N$#')),
                                     true
                                   ),
                                   '$s',
                                   ' '
                                 ),
                                 '$#',
                                 IntToStr(OpenFileID)
                               );
          end
          else if not (List.Items[i] = '') then
          begin
            if regexpr.Exec(List.Items[i]) then
              List.Items[i] := SysFuncs.SearchAndReplace(
                                 SysFuncs.SearchAndReplace(
                                   regexpr.Replace(
                                     List.Items[i],
                                     stx.ReadString('Replace','NumSign',
                                       ini.ReadString('Number','Sign','N$#$s$2')),
                                     true
                                   ),
                                   '$s',
                                   ' '
                                 ),
                                 '$#',
                                 IntToStr(j)
                               )
            else
              List.Items[i] := SysFuncs.SearchAndReplace(
                                 SysFuncs.SearchAndReplace(
                                   SysFuncs.SearchAndReplace(
                                     stx.ReadString('Replace','NumSignIns',
                                       ini.ReadString('Number','SignIns','N$#$s$a')),
                                     '$a',
                                     List.Items[i]
                                   ),
                                   '$s',
                                   ' '
                                 ),
                                 '$#',
                                 IntToStr(j)
                               );
              //showmessage (List.Items[i]);
          end;
        end;
        List.Items[i] := CorrectLine(List.Items[i]);
        i := i + 1;
        j := j + ini.ReadInteger('Number','Width',1);
      end;

    finally
      regexpr.Free;
      end;

    if not (List.Items[List.Count-1] = '') then
      List.Items.Add('');

    List.Items.EndUpdate;
  end;
Code:
N568993 
N1 (***)
N2 G98 X-10 Y-10 Z-40 I320 J170 K50 
N3 G99 X0 Y0 Z0 I300 J150 K-30 
N4 F150 S1000 T5 M6 
N5 M13 
N6 G0 Z100 
N7 G0 X30 Y20 
N8 G0 Z2 
N9 (***)
N10 G89 Z-19 B1 R19 I50 J1 K5 
N11 G79 X30 Y20 Z0 
N12 G0 Z30 
N13 G0 X260 Y30 
N14 G0 Z2 
N15 (***)
N16 G89 Z-19 B1 R29 I50 J1 K5 
N17 G79 X260 Y30 Z0 
N18 G0 Z30 
N19 G0 X150 Y17 
N20 G0 Z2 
N21 (***)
N22 G87 X230 Y34 Z-19 B1 I50 J1 K5 
N23 G79 X150 Y17 Z0 
N24 G0 Z30 
N25 G0 X30 Y10 
N26 G0 Z2 
N27 (***)
N28 G87 X38 Y30 Z-19 B1 I50 J1 K5 
N29 G79 X30 Y5 Z0 
N30 G0 Z30 
N31 G0 X255 Y10 
N32 G0 Z2 
N33 (***)
N34 G87 X40 Y40 Z-19 B1 I50 J1 K5 
N35 G79 X254 Y10 Z0 
N36 G0 Z30 
...
N146 G0 Z100 
N147 M30
  Mit Zitat antworten Zitat