Examples Delphi

procedure TForm1.ExtractWords;
{currently we are using the DICT.ASC dictionary file to load into
memory. This file is 316K in size and has words separated by commas
(which we then parse out into separate words here) -so, i) do we really
want to have a memory-resident dictionary? ii) there may be a better
dictionary to use, and iii) we might be better off using an encrypted
dictionary for instance...}
{parse out one word at a time from the (comma-delimited) text file...
this procedure also involves some 'low-level' stuff -it's necessary
to work chunks of text in the form of a 'null-terminated string' in
the form of a character array, and then convert that to Delphi's
kind of string...}
var
i,pos,x,y: Integer;
charsLen: Integer;
thisChunk: array [1..30] of Char;
thisWord: String;
begin
i := 1;
pos := 1;
for x := 1 to 30 do
begin
thisChunk[x] := #0;
end;
charsLen := GetWordsEnd;
while (i < charsLen) do
begin
while ((not(dictBuf[i] = ',') and (i < charsLen))) do
begin
Inc(i);
end;
y := 1;
for x := pos to (i - 1) do
begin
thisChunk[y] := dictBuf[x];
Inc(y);
end;
{use a typecast to convert from character array to string...}
thisWord := string(thisChunk);
{the commented-out call to TempFindMatch below is a brief routine
to test our ability to search in the memory-resident dictionary.
It works, (showing a message box on startup to say that there is a
match for 'tree' in the dictionary) but being just a v. basic test
we need to DO MUCH TO IMPROVE THIS if we decide to keep a mem-res
dictionary etc...}
{TempFindMatch(thisWord);}
{skip a comma by incrementing i...}
Inc(i);
pos := i;
for x := 1 to 30 do
begin
thisChunk[x] := #0;
end;
end; {outer while}
end;