diff options
Diffstat (limited to 'packages/aspell/examples/example.pas')
| -rw-r--r-- | packages/aspell/examples/example.pas | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/packages/aspell/examples/example.pas b/packages/aspell/examples/example.pas index 62359451f8..8f5221bda2 100644 --- a/packages/aspell/examples/example.pas +++ b/packages/aspell/examples/example.pas @@ -3,24 +3,32 @@ program Example; {$mode objfpc}{$H+} uses - sCheck; + SpellCheck; var - i, j, n: Integer; + i, j: Integer; s: TSuggestionArray; { in case the word is wrong, this array contains a list of suggestions } + Speller: TWordSpeller; begin if Paramcount < 2 then // check if user has used valid input Writeln('Usage: ', ParamStr(0), ' <lang> <word1> <word2> ...') - else for i := 2 to ParamCount do begin // go for each word specified - n := SpellCheck(ParamStr(i), ParamStr(1), s); // spellcheck each word - if n > 0 then begin // if n > 0 then the word is wrong and we need to write suggestions - Write(ParamStr(i), ' is wrong. Here are some suggestions: '); - for j := 0 to High(s) do - Write(s[j], ' '); // write out the suggestions - Writeln; // to keep format - end else - Writeln(ParamStr(i), ' is spelled correctly!'); + else begin + Speller := TWordSpeller.Create; + Speller.Language := ParamStr(1); + + for i := 2 to ParamCount do begin // go for each word specified + s := Speller.SpellCheck(ParamStr(i)); // spellcheck each word + if Length(s) > 0 then begin // we need to write suggestions + Write(ParamStr(i), ' is wrong. Here are some suggestions: '); + for j := 0 to High(s) do + Write(s[j], ' '); // write out the suggestions + Writeln; // to keep format + end else + Writeln(ParamStr(i), ' is spelled correctly!'); + end; + + Speller.Free; end; end. |
