Skip to main content
Version: Next

SPELL CHECK TEXT

SPELL CHECK TEXT ( text ; errPos ; errLength ; checkPos ; arrSuggest )

ParameterTypeDescription
textTextText to check
errPosIntegerPosition of first character of unknown word
errLengthIntegerLength of unknown word
checkPosIntegerStart position for check
arrSuggestText arrayList of suggestions

This command is not thread-safe, it cannot be used in preemptive code.

Description

The SPELL CHECK TEXT command checks the contents of the text parameter beginning from the checkPos character and returns the position of the first unknown word it finds (if any).

This command returns the position of the first character of this unknown word in errPos and its length in errLength. The arrSuggest array receives the correction suggestion(s) proposed by the spell checker.

If the check starts without error and an unknown word is found, the OK system variable is set to 0. If an initialization error occurs during the check, or if no unknown words are found, OK is set to 1.

Note OS X: Under OS X, when the native spell checker is enabled, this command does not support grammar correction.

Example

We want to count the number of possible errors in a text:

 $pos:=1
 $errCount:=0
 ARRAY TEXT($tErrors;0)
 ARRAY TEXT($tSuggestions;0)
 Repeat
    SPELL CHECK TEXT($myText;$errPos;$errLength;$pos;$tSuggestions)
    If(OK=0)
       $errCount:=$errCount+1 // count any errors
       $errorWord:=Substring($myText;$errPos;$errLength)
       APPEND TO ARRAY($tErrors;$errorWord) // array of errors
       $pos:=$errPos+$errLength  //continue check
    End if
 Until(OK=1)
  // In the end $errCount=Size of array($tErrors)

See also

SPELL ADD TO USER DICTIONARY
SPELL CHECKING