| ESBPosNCh Function | 
Unit
QESBPCSConvert
Declaration
Function ESBPosNCh(const Ch: Char; const S: string; const N: Integer; Start: Integer = 1): Integer;
Description
Can optionally have a starting point.
| Parameters | 
| Ch | Character to be searched for | 
| S | String to Search within | 
| N | is the Occurrence that is being looked for. If N < 1 then 0 is returned. | 
| Start | Character Position at which to start. If Start < 1 then 1 is used. If Start > Length (S) then 0 is returned. | 
Returns
The Position of the Character, otherwise 0 is returned.
Category
Extra String Handling RoutinesImplementation
 
| function ESBPosNCh (const Ch: Char; const S: string; const N: Integer;
     Start: Integer = 1): Integer;
var
     I, Len, Count: Integer;
begin
     Result := 0;
     Len := Length (S);
     if Start < 1 then
          Start := 1;
     if (Len = 0) or (Start > Len) or (N < 1) then
          Exit;
     Count := 0;
     for I := Start to Len do
     begin
          if S [I] = Ch then
          begin
               Inc (Count);
               if Count = N then
               begin
                    Result := I;
                    Exit;
               end;
          end;
     end;
End; | 
|  |