{$V-,A-,D-,L-}
Program XWords;
  uses CRT;

var
   Wordfile : Text;
   filenumber : String[2];
   DictWord, TestWord, Exclude : string[20];
   i, j, Len, LenExclude, total : integer;

begin
TestWord := ParamStr(1);
Exclude := ParamStr(2);
Len := length(TestWord);
if (len < 2) or (len > 18) then len := 2;
LenExclude := Length(Exclude);
str(len,FileNumber);
For i := 1 to Len do TestWord[i] := Upcase(TestWord[i]);
For i := 1 to LenExclude do Exclude[i] := UpCase(Exclude[i]);
write('Searching WORDS'+FileNumber+' for '+TestWord+' ');
Assign(Wordfile,'WORDS'+FileNumber+'.DAT');
Reset(Wordfile);
if LenExclude > 0 then Writeln('excluding ',Exclude) else WriteLn;
while not eof(Wordfile) do begin
   readln(Wordfile, DictWord);
   total := 0;
   if LenExclude > 0 Then Begin
      For i := 1 to LenExclude do
      if Pos(Exclude[i],DictWord) > 0 then Total := 1;
   End;
   if Total = 0 Then Begin
      for i := 1 to Len do begin
          if (TestWord[i] = '?') or (TestWord[i] = DictWord[i]) then Inc(total);
          if total = Len then begin
             For i := 1 to Len do Begin
                 For j := 1 to Len do Begin
                 if j<>i then if DictWord[i] = TestWord[j] then if TestWord[i] <> TestWord[j] then Textcolor(6);
                 End;
             End;
             write(DictWord,'  ');
             if wherex > 79-Len then writeln;
             Textcolor(7);
          end;
      end;
   end;
 end;
 Writeln;
 Close(Wordfile);
end.
