Guest User

Untitled

a guest
Feb 20th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. type
  2. TStringArray = array of string;
  3.  
  4. function StringSplit(const what : string; const delim : string) : TStringArray;
  5. var
  6. a : TStringArray;
  7. tmps : string;
  8. idx, size, to_pos : Integer;
  9. was_end : Boolean;
  10.  
  11. begin
  12. was_end := False;
  13. tmps := what;
  14. size := CharCount(delim[1], what) + 1;
  15. SetLength(a, size+1);
  16.  
  17. for idx := 1 to size do
  18. begin
  19. to_pos := Pos(delim, tmps)-1;
  20. if to_pos = -1 then
  21. begin
  22. to_pos := Length(tmps);
  23. was_end := True;
  24. end;
  25.  
  26. a[idx] := Copy(tmps, 0, to_pos);
  27. if was_end then Break;
  28. Delete(tmps, 1, to_pos+1);
  29. end;
  30.  
  31. StringSplit := a;
  32. end;
Add Comment
Please, Sign In to add comment