Ignore:
Timestamp:
Aug 12, 2009, 7:14:16 PM (15 years ago)
Author:
Kevin Toppenberg
Message:

TMG Ver 1.1 Added HTML Support, better demographics editing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cprs/branches/tmg-cprs/CPRS-Lib/ORFn.pas

    r453 r541  
    5454procedure MixedCaseList(AList: TStrings);
    5555procedure 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;
     56function Piece(const S: string; Delim: char; PieceNum: Integer): string;  overload;     //kt 8/09 added 'overload'
     57function Piece(const S: string; Delim: string; PieceNum: Integer): string; overload;    //kt 8/09
     58function PieceNCS(const S: string; Delim: string; PieceNum: Integer): string; overload; //kt 8/09
     59function Pieces(const S: string; Delim: char; FirstNum, LastNum: Integer): string; overload;     //kt 8/09 added 'overload'
     60function Pieces(const S: string; Delim: string; PieceStart,PieceEnd: Integer): string; overload; //kt 8/09 added
     61function PiecesNCS(const S: string; Delim: string; PieceStart,PieceEnd: Integer): string;        //kt 8/09 added
    5862function ComparePieces(P1, P2: string; Pieces: array of integer; Delim:
    5963                       char = '^'; CaseInsensitive: boolean = FALSE): integer;
     
    120124
    121125uses
     126  StrUtils,  //kt 8/09
    122127  ORCtrls, Grids, Chart, CheckLst;
    123128
     
    604609end;
    605610
    606 function Piece(const S: string; Delim: char; PieceNum: Integer): string;
     611function Piece(const S: string; Delim: char; PieceNum: Integer): string; overload; //kt 8/09 added 'overload;'
    607612{ returns the Nth piece (PieceNum) of a string delimited by Delim }
    608613var
     
    623628end;
    624629
     630function 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
     633var tempS : string;
     634begin
     635  tempS := AnsiReplaceText(S,Delim,UpperCase(Delim));
     636  Result := Piece(tempS,UpperCase(Delim),PieceNum);
     637end;
     638
     639function Piece(const S: string; Delim: string; PieceNum: Integer): string; overload;
     640//kt 8/09 Added entire function
     641var Remainder : String;
     642    PieceLen,p : integer;
     643begin
     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;
     654end;
     655
     656function Pieces(const S: string; Delim: string; PieceStart,PieceEnd: Integer): string; overload;
     657//kt 8/09 Added entire function
     658var Remainder : String;
     659    PieceNum : integer;
     660    PieceLen,p : integer;
     661begin
     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;
     683end;
     684
    625685function Pieces(const S: string; Delim: char; FirstNum, LastNum: Integer): string;
    626686{ returns several contiguous pieces }
     
    631691  for PieceNum := FirstNum to LastNum do Result := Result + Piece(S, Delim, PieceNum) + Delim;
    632692  if Length(Result) > 0 then Delete(Result, Length(Result), 1);
     693end;
     694
     695function 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
     698var tempS : string;
     699begin
     700  tempS := AnsiReplaceText(S,Delim,UpperCase(Delim));
     701  Result := Pieces(tempS,UpperCase(Delim),PieceStart,PieceEnd);
    633702end;
    634703
Note: See TracChangeset for help on using the changeset viewer.