Advertisement
mixster

mixster

Aug 7th, 2009
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.51 KB | None | 0 0
  1. {*******************************************************************************
  2. function srl_Explode(str, del: string): TStringArray;
  3. By: mixster
  4. Description: Explodes a string into a TStringArray, seperated by del.
  5. *******************************************************************************}
  6.  
  7. function srl_Explode(str, del: string): TStringArray;
  8. var
  9.   i, l, dL: Integer;
  10. begin
  11.   {$IFDEF SCAR320_UP}
  12.     Result := Explode(del, str);
  13.   {$ELSE}
  14.     i := 0;
  15.     l := -1;
  16.     SetLength(Result, 0);
  17.     if (str = '') then
  18.       Exit;
  19.     dL := Length(del) - 1;
  20.     repeat
  21.       Inc(l);
  22.       SetLength(Result, l + 1);
  23.       i := Pos(del, str);
  24.       if i <= 0 then
  25.         Break;
  26.       Result[l] := Copy(str, 1, i - 1);
  27.       Delete(str, 1, i + dL);
  28.     until false
  29.     Result[l] := Copy(str, 1, Length(str));
  30.   {$ENDIF}
  31. end;
  32.  
  33. {*******************************************************************************
  34. function srl_Implode(Pieces: TStringArray; Separator: string): string;
  35. By: ZephyrsFury
  36. Description: Combines Pieces in a single string separated by a Separator.
  37. *******************************************************************************}
  38.  
  39. function srl_Implode(Pieces: TStringArray; Glue: string): string;
  40. var
  41.   II, H: Integer;
  42. begin
  43.   {$IFDEF SCAR320_UP}
  44.     Result := Implode(glue, pieces);
  45.   {$ELSE}
  46.     H := High(Pieces);
  47.     if (H < 0) then Exit;
  48.     Result := Pieces[0];
  49.     if H > 0 then
  50.       for II := 1 to H do
  51.         Result := Result + Glue + Pieces[II];
  52.   {$ENDIF}
  53. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement