example.pas 840 B

1234567891011121314151617181920212223242526
  1. program Example;
  2. {$mode objfpc}{$H+}
  3. uses
  4. sCheck;
  5. var
  6. i, j, n: Integer;
  7. s: TSuggestionArray; { in case the word is wrong, this array contains
  8. a list of suggestions }
  9. begin
  10. if Paramcount < 2 then // check if user has used valid input
  11. Writeln('Usage: ', ParamStr(0), ' <lang> <word1> <word2> ...')
  12. else for i := 2 to ParamCount do begin // go for each word specified
  13. n := SpellCheck(ParamStr(i), ParamStr(1), s); // spellcheck each word
  14. if n > 0 then begin // if n > 0 then the word is wrong and we need to write suggestions
  15. Write(ParamStr(i), ' is wrong. Here are some suggestions: ');
  16. for j := 0 to High(s) do
  17. Write(s[j], ' '); // write out the suggestions
  18. Writeln; // to keep format
  19. end else
  20. Writeln(ParamStr(i), ' is spelled correctly!');
  21. end;
  22. end.