k:=0; index:=0; for i:=1 to length(str) do if str[i]=',' then begin k:=k+1; if k=4 then begin Index:=i; Break; end; end;