Changeset 541 for cprs/branches/tmg-cprs/CPRS-Lib
- Timestamp:
- Aug 12, 2009, 7:14:16 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cprs/branches/tmg-cprs/CPRS-Lib/ORFn.pas
r453 r541 54 54 procedure MixedCaseList(AList: TStrings); 55 55 procedure MixedCaseByPiece(AList: TStrings; ADelim: Char; PieceNum: Integer); 56 function Piece(const S: string; Delim: char; PieceNum: Integer): string; 57 function Pieces(const S: string; Delim: char; FirstNum, LastNum: Integer): string; 56 function Piece(const S: string; Delim: char; PieceNum: Integer): string; overload; //kt 8/09 added 'overload' 57 function Piece(const S: string; Delim: string; PieceNum: Integer): string; overload; //kt 8/09 58 function PieceNCS(const S: string; Delim: string; PieceNum: Integer): string; overload; //kt 8/09 59 function Pieces(const S: string; Delim: char; FirstNum, LastNum: Integer): string; overload; //kt 8/09 added 'overload' 60 function Pieces(const S: string; Delim: string; PieceStart,PieceEnd: Integer): string; overload; //kt 8/09 added 61 function PiecesNCS(const S: string; Delim: string; PieceStart,PieceEnd: Integer): string; //kt 8/09 added 58 62 function ComparePieces(P1, P2: string; Pieces: array of integer; Delim: 59 63 char = '^'; CaseInsensitive: boolean = FALSE): integer; … … 120 124 121 125 uses 126 StrUtils, //kt 8/09 122 127 ORCtrls, Grids, Chart, CheckLst; 123 128 … … 604 609 end; 605 610 606 function Piece(const S: string; Delim: char; PieceNum: Integer): string; 611 function Piece(const S: string; Delim: char; PieceNum: Integer): string; overload; //kt 8/09 added 'overload;' 607 612 { returns the Nth piece (PieceNum) of a string delimited by Delim } 608 613 var … … 623 628 end; 624 629 630 function PieceNCS(const S: string; Delim: string; PieceNum: Integer): string; overload; 631 //kt 8/09 Name means Piece-Not-Case-Sensitive, meaning match for Delim is not case sensitive. 632 //kt 8/09 Added entire function 633 var tempS : string; 634 begin 635 tempS := AnsiReplaceText(S,Delim,UpperCase(Delim)); 636 Result := Piece(tempS,UpperCase(Delim),PieceNum); 637 end; 638 639 function Piece(const S: string; Delim: string; PieceNum: Integer): string; overload; 640 //kt 8/09 Added entire function 641 var Remainder : String; 642 PieceLen,p : integer; 643 begin 644 Remainder := S; 645 Result := ''; 646 PieceLen := Length(Delim); 647 while (PieceNum > 0) and (Length(Remainder) > 0) do begin 648 p := Pos(Delim,Remainder); 649 if p=0 then p := length(Remainder)+1; 650 Result := MidStr(Remainder,1,p-1); 651 Remainder := MidStr(Remainder,p+PieceLen,9999); 652 Dec(PieceNum); 653 end; 654 end; 655 656 function Pieces(const S: string; Delim: string; PieceStart,PieceEnd: Integer): string; overload; 657 //kt 8/09 Added entire function 658 var Remainder : String; 659 PieceNum : integer; 660 PieceLen,p : integer; 661 begin 662 Remainder := S; 663 Result := ''; 664 PieceLen := Length(Delim); 665 PieceNum := PieceStart; 666 while (PieceNum > 1) and (Length(Remainder) > 0) do begin 667 p := Pos(Delim,Remainder); 668 if p=0 then p := length(Remainder)+1; 669 Result := MidStr(Remainder,1,p-1); 670 Remainder := MidStr(Remainder,p+PieceLen,9999); 671 Dec(PieceNum); 672 end; 673 PieceNum := PieceEnd-PieceStart+1; 674 Result := ''; 675 while (PieceNum > 0) and (Length(Remainder) > 0) do begin 676 p := Pos(Delim,Remainder); 677 if p=0 then p := length(Remainder)+1; 678 if Result <> '' then Result := Result + Delim; 679 Result := Result + MidStr(Remainder,1,p-1); 680 Remainder := MidStr(Remainder,p+PieceLen,9999); 681 Dec(PieceNum); 682 end; 683 end; 684 625 685 function Pieces(const S: string; Delim: char; FirstNum, LastNum: Integer): string; 626 686 { returns several contiguous pieces } … … 631 691 for PieceNum := FirstNum to LastNum do Result := Result + Piece(S, Delim, PieceNum) + Delim; 632 692 if Length(Result) > 0 then Delete(Result, Length(Result), 1); 693 end; 694 695 function PiecesNCS(const S: string; Delim: string; PieceStart,PieceEnd: Integer): string; 696 //kt 8/09 Name means Pieces-Not-Case-Sensitive, meaning match for Delim is not case sensitive. 697 //kt 8/09 Added entire function 698 var tempS : string; 699 begin 700 tempS := AnsiReplaceText(S,Delim,UpperCase(Delim)); 701 Result := Pieces(tempS,UpperCase(Delim),PieceStart,PieceEnd); 633 702 end; 634 703
Note:
See TracChangeset
for help on using the changeset viewer.