Browse Source

* add an example for the SpellCheck()

git-svn-id: trunk@8378 -
Almindor 18 years ago
parent
commit
3f123fa0aa
2 changed files with 27 additions and 0 deletions
  1. 1 0
      .gitattributes
  2. 26 0
      packages/extra/aspell/example.pas

+ 1 - 0
.gitattributes

@@ -1904,6 +1904,7 @@ packages/extra/aspell/LICENSE.ADDON -text
 packages/extra/aspell/Makefile svneol=native#text/plain
 packages/extra/aspell/Makefile.fpc svneol=native#text/plain
 packages/extra/aspell/aspell.pp svneol=native#text/plain
+packages/extra/aspell/example.pas svneol=native#text/plain
 packages/extra/aspell/fpmake.inc svneol=native#text/plain
 packages/extra/aspell/fpmake.pp svneol=native#text/plain
 packages/extra/aspell/scheck.pp svneol=native#text/plain

+ 26 - 0
packages/extra/aspell/example.pas

@@ -0,0 +1,26 @@
+program Example;
+
+{$mode objfpc}{$H+}
+
+uses
+  sCheck;
+
+var
+  i, j, n: Integer;
+  s: TSuggestionArray; { in case the word is wrong, this array contains
+                         a list of suggestions }
+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!');
+  end;
+end.
+