I have the following split function in Delphi works perfect the problem is I want to improve the code to not use repeat-until more but not that another way to do it.
type
TSarray = array of string;
function Split(Texto, Delimitador: string): TSarray;
var
o: integer;
PosDel: integer;
Aux: string;
begin
o := 0;
Aux := Texto;
SetLength(Result, Length(Aux));
repeat
PosDel := Pos(Delimitador, Aux) - 1;
if PosDel = -1 then
begin
Result[o] := Aux;
break;
end;
Result[o] := copy(Aux, 1, PosDel);
delete(Aux, 1, PosDel + Length(Delimitador));
inc(o);
until Aux = '';
end;
Example:
var texto,deli:string;
all_array:TSarray;
begin
deli := 'test';
texto := deli+'hi world 1'+deli+'hi world 2'+deli;
end;
all_array := Split(texto,deli);
ShowMessage(all_array[1]);
ShowMessage(all_array[2]);
end;
My plan is to use no classes, only the "uses" default
What alternatives do I have to repeat-until?