function TForm1.GetWordsEnd: Integer;
{find the end of the usable data in the (dictionary) buffer...}
type
TdataChars = set of Char;
var
dataChars: TdataChars;
len: Integer;
textEnd: Boolean;
begin
{define the SET of characters of which the data is comprised...
note: any change to the file where extra characters are added will
therefore screw up the program. For that reason one must be careful
that this definition is always in synch with the nature of the data
file and also this definition is probably better defined elsewhere
as a global constant of some sort}
dataChars := ['A'..'Z', 'a'..'z', ','];
len := 1;
textEnd := False;
while ((textEnd = False) and (len < bufSize)) do
begin
if (dictBuf[len] in dataChars) then
begin
Inc(len);
end
else
begin
textEnd := True;
end;
end;
Result := len;
end;