Martin, try this. Drop a button and an editbox on a form and try the following code.
type
DelimSet = set of Char;
function WordPos(N : Integer ; S : string; Delims : DelimSet) : Integer ;
var
ii,iLength,iCount : Integer;
begin
Result := 0; { default }
iLength := Length(S);
iCount := 0...