Changeset 186
- Timestamp:
- Jul 11, 2018, 3:34:11 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormCheck.pas
r185 r186 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 ExtCtrls, ComCtrls, UAcronym, URegistry, Registry ;9 ExtCtrls, ComCtrls, UAcronym, URegistry, Registry, UCommon; 10 10 11 11 type … … 49 49 function SearchLine(Lines: TStrings; Text: string; Start: Integer = 0): Integer; 50 50 function SearchLineReverse(Lines: TStrings; Text: string; Start: Integer = -1): Integer; 51 function PosFromIndex(SubStr: string; Text: string; StartIndex: Integer): Integer;52 function PosFromIndexReverse(SubStr: string; Text: string; StartIndex: Integer): Integer;53 51 procedure FindInSummary; 54 52 procedure FindInContent; … … 173 171 else Result := Start; 174 172 while (Result >= 0) and (Pos(Text, Lines[Result]) = 0) do Dec(Result); 175 end;176 177 function TFormCheck.PosFromIndex(SubStr: string; Text: string;178 StartIndex: Integer): Integer;179 begin180 Delete(Text, 1, StartIndex);181 Result := Pos(SubStr, Text);182 if Result <> 0 then Result := Result + StartIndex;183 end;184 185 function TFormCheck.PosFromIndexReverse(SubStr: string; Text: string;186 StartIndex: Integer): Integer;187 begin188 Delete(Text, StartIndex + 1, Length(Text));189 Result := LastDelimiter(SubStr, Text);190 173 end; 191 174 -
trunk/Packages/Common/UCommon.pas
r181 r186 75 75 FilterMethod: TFilterMethodMethod); 76 76 function GetStringPart(var Text: string; Separator: string): string; 77 function PosFromIndex(SubStr: string; Text: string; 78 StartIndex: Integer): Integer; 79 function PosFromIndexReverse(SubStr: string; Text: string; 80 StartIndex: Integer): Integer; 77 81 78 82 … … 559 563 end; 560 564 561 565 function PosFromIndex(SubStr: string; Text: string; 566 StartIndex: Integer): Integer; 567 var 568 I, MaxLen: SizeInt; 569 Ptr: PAnsiChar; 570 begin 571 Result := 0; 572 if (StartIndex < 1) or (StartIndex > Length(Text) - Length(SubStr)) then Exit; 573 if Length(SubStr) > 0 then begin 574 MaxLen := Length(Text) - Length(SubStr) + 1; 575 I := StartIndex; 576 Ptr := @Text[StartIndex]; 577 while (I <= MaxLen) do begin 578 if (SubStr[1] = Ptr^) and (CompareByte(Substr[1], Ptr^, Length(SubStr)) = 0) then begin 579 Result := I; 580 Exit; 581 end; 582 Inc(I); 583 Inc(Ptr); 584 end; 585 end; 586 end; 587 588 function PosFromIndexReverse(SubStr: string; Text: string; 589 StartIndex: Integer): Integer; 590 var 591 I: SizeInt; 592 Ptr: PAnsiChar; 593 begin 594 Result := 0; 595 if (StartIndex < 1) or (StartIndex > Length(Text)) then Exit; 596 if Length(SubStr) > 0 then begin 597 I := StartIndex; 598 Ptr := @Text[StartIndex]; 599 while (I > 0) do begin 600 if (SubStr[1] = Ptr^) and (CompareByte(Substr[1], Ptr^, Length(SubStr)) = 0) then begin 601 Result := I; 602 Exit; 603 end; 604 Dec(I); 605 Dec(Ptr); 606 end; 607 end; 608 end; 562 609 563 610 initialization
Note:
See TracChangeset
for help on using the changeset viewer.