{ --- Locator functions --- }

function previous_word(i:integer): integer;
begin
if (text[i] in alphanums) and (text[i-1] in alphanums) then
    while (i>1) and (text[i] in alphanums) do i:=i-1
else
    begin
    i:=i-1;
    while (i>1) and (text[i] in separators) do i:=i-1;
    while (i>1) and (text[i] in alphanums) do  i:=i-1;
    end;
if text[i] in separators then i:=i+1;
previous_word:=i;
end; { previous_word }

function next_word(i:integer): integer;
begin
while (i<text_length) and (text[i] in alphanums) do i:=i+1;
while (i<text_length) and (text[i] in separators) do i:=i+1;
if (i=text_length) and (text[i]<>CR) then next_word:=i+1 else next_word:=i;
end; { next_word }

