Word wheel: Difference between revisions

Content added Content deleted
No edit summary
Line 1,808: Line 1,808:
begin
begin
AssignFile(WordList, WordFile);
AssignFile(WordList, WordFile);
{$I-}
try
Reset(WordList);
Reset(WordList);
{$I+}
except
writeln('Could not open dictionary file ' + WordFile);
if IOResult <> 0 then
begin
exit;
end;
writeln('Could not open dictionary file ' + WordFile);
exit;
end;
Allowed := LowerCase(pattern);
Allowed := LowerCase(pattern);
Required := copy(Allowed, 5, 1);
Required := copy(Allowed, 5, 1); { central letter is required }
while not eof(WordList) do
while not eof(WordList) do
begin
begin
readln(WordList, w);
readln(WordList, w);
Len := length(w);
Len := length(w);
Available := Allowed;
if (Len < MinLength) or (Len > WheelSize) then continue;
if (Len < MinLength) or (Len > WheelSize) then continue;
if pos(Required, w) = 0 then continue;
if pos(Required, w) = 0 then continue;
Available := Allowed;
Match := True;
Match := True;
for i := 1 to Len do
for i := 1 to Len do
Line 1,845: Line 1,843:
{ exercise the procedure }
{ exercise the procedure }
begin
begin
search('NDEOKGELW');
search('NDE' + 'OKG' + 'ELW'); {3 x 3 letter grid }
end.
end.
</lang>
</lang>