Hello copy dont work for me if im use me function this return me fasola do remi why not fasola?
if im use text[pos2] this return good letter fasol>>>a<<<
function GetPiece2(text,pos:string;num:integer):string;
var i,findpos,pos1,pos2: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
pos2:=i-1; //debug
WriteLn(inttostr(pos2)+' '+text[pos2]); //debug
Result:=Copy(text,pos1,i-1);
exit;
end;
end;
end else
begin
if i=length(text) then begin
Result:=Copy(text,pos1,length(text));
exit;
end;
end;
end;
end;
procedure ActivateServer();
var b: byte; Temp: TStringList; stong:string;
begin
stong := 'Do remi fasola do remi';
WriteLn(GetPiece2(Stong,' ',2)+'-TEST!');