Changeset 200 for trunk/Packages/Common/UCommon.pas
- Timestamp:
- Aug 31, 2018, 3:38:01 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/UCommon.pas
r187 r200 72 72 function MergeArray(A, B: array of string): TArrayOfString; 73 73 function LoadFileToStr(const FileName: TFileName): AnsiString; 74 procedure SaveStringToFile(S, FileName: string); 74 75 procedure SearchFiles(AList: TStrings; Dir: string; 75 76 FilterMethod: TFilterMethodMethod = nil); 76 77 function GetStringPart(var Text: string; Separator: string): string; 78 function StripTags(const S: string): string; 77 79 function PosFromIndex(SubStr: string; Text: string; 78 80 StartIndex: Integer): Integer; … … 527 529 end; 528 530 531 procedure SaveStringToFile(S, FileName: string); 532 var 533 F: TextFile; 534 begin 535 AssignFile(F, FileName); 536 try 537 ReWrite(F); 538 Write(F, S); 539 finally 540 CloseFile(F); 541 end; 542 end; 543 529 544 procedure SearchFiles(AList: TStrings; Dir: string; 530 545 FilterMethod: TFilterMethodMethod = nil); … … 561 576 Result := Trim(Result); 562 577 Text := Trim(Text); 578 end; 579 580 function StripTags(const S: string): string; 581 var 582 Len: Integer; 583 584 function ReadUntil(const ReadFrom: Integer; const C: Char): Integer; 585 var 586 J: Integer; 587 begin 588 for J := ReadFrom to Len do 589 if (S[j] = C) then 590 begin 591 Result := J; 592 Exit; 593 end; 594 Result := Len + 1; 595 end; 596 597 var 598 I, APos: Integer; 599 begin 600 Len := Length(S); 601 I := 0; 602 Result := ''; 603 while (I <= Len) do begin 604 Inc(I); 605 APos := ReadUntil(I, '<'); 606 Result := Result + Copy(S, I, APos - i); 607 I := ReadUntil(APos + 1, '>'); 608 end; 563 609 end; 564 610 … … 608 654 end; 609 655 656 610 657 initialization 611 658
Note:
See TracChangeset
for help on using the changeset viewer.