Official Soldat Forums

Server Talk => Scripting Releases => Topic started by: soldat-game on July 24, 2016, 12:36:29 pm

Title: function GetPiece2(text,pos:string;num:integer):string;
Post by: soldat-game on July 24, 2016, 12:36:29 pm
If  you need a getpiece function in script core III

Code: [Select]
function GetPiece2(text,pos:string;num:integer):string;
var i,findpos,pos1:integer;
begin
findpos:=0;
Result:='';
for i := 1 to length(text) do begin
if text[i]=pos then begin
if num=0 then begin
Result:=Copy(text,1,i-1);
exit;
end else
begin
findpos:=findpos+1;
if findpos=num then pos1:=i+1;
if findpos=num+1 then begin
Result:=Copy(text,pos1,i-pos1);
exit;
end;
end;
end else
begin
if i=length(text) then begin
Result:=Copy(text,pos1,length(text));
exit;
end;
end;
end;
end;