Registriert seit: 23. Jul 2004
Ort: Bonn
30 Beiträge
Delphi 7 Professional
|
Re: Regulär bis zum abwinken
14. Mai 2006, 16:57
Hallo,
hier der Code. In dieser Version funkt alles.
Delphi-Quellcode:
//------------------------------------------------------------------------------
// Procedure : AddToDos
//------------------------------------------------------------------------------
procedure TToDoForm.AddToDos;
var
i, iPrio, iIndex, iP1, iP2, iP3: Integer;
sOwner: string;
sCategory: string;
sDate:string;
sToDo: string;
sModule: string;
iToDoPos: Integer;
iToDoLenght: Integer;
iLine: TBufferCoord;
procedure AddItem(iIndex, iLine, iLen, iPos: Integer; sToDo, sModule, sOwner, sCategory, sDate: string);
begin
with lvToDo.Items.Add do begin
ImageIndex := iIndex;
// Module
Caption := sModule;
// Owner
SubItems.Add(sOwner);
// Category
SubItems.Add(sCategory);
// Module
SubItems.Add(sDate);
// Line
SubItems.Add(IntToStr(iLine));
// Lenght
SubItems.Add(IntToStr(iLen));
// Pos
SubItems.Add(IntToStr(iPos));
// ToDo
SubItems.Add(sToDo);
end;
end;
begin
iP1 := 0;
iP2 := 0;
iP3 := 0;
lvToDo.Items.BeginUpdate;
lvToDo.Items.Clear;
// Dieser Text wird geparst
fRegEx.InputString := fLinesNew.Text;
// Const expToDos = '/\*\s+TODO\s+(\d+)\s+-o(.*)\s+-c(.*)\s+:\s+(.*)\*/'; in uConsts.pas
fRegEx.Expression := expToDos;
fRegEx.Compile;
fRegEx.ModifierStr := 'mis-g';
i := 1;
while fRegEx.ExecPos(i) do begin
iToDoPos := fRegEx.MatchPos[0];
iToDoLenght := fRegEx.MatchLen[0];
iPrio := StrToIntDef(fRegEx.Match[1], 0);
sOwner := fRegEx.Match[2];
sCategory := fRegEx.Match[3];
sDate := fRegEx.Match[4];
sToDo := ClearNl(fRegEx.Match[5]);
if Document <> nil then
sModule := Document.FileName;
iLine := Document.CharIndexToRowCol(iToDoPos);
case iPrio of
1: begin
iIndex := 0;
Inc(iP1);
// For Filter
AddItem(iIndex, iLine.Line, iToDoLenght, iToDoPos, sToDo, sModule, sOwner, sCategory, sDate);
end;
2: begin
iIndex := 1;
Inc(iP2);
// For Filter
AddItem(iIndex, iLine.Line, iToDoLenght, iToDoPos, sToDo, sModule, sOwner, sCategory, sDate);
end;
3: begin
iIndex := 2;
Inc(iP3);
// For Filter
AddItem(iIndex, iLine.Line, iToDoLenght, iToDoPos, sToDo, sModule, sOwner, sCategory, sDate);
end;
end;
i := fRegEx.MatchPos[0] + fRegEx.MatchLen[0];
end;
lvToDo.Items.EndUpdate;
StatusMsg(iP1, iP2, iP3);
end;
wie gesagt die andere Version mit (TODO|DONE) Matched nichts.
gruss Andreas.
Bei schwierigen Problemen entscheiden wir uns einfach für die richtige Lösung.
|