This section will explain how you can use the spell checker library from your own libraries and how to translate the librarys literal text. The software ships with the library called example.lbr and the data file example.df1. The example library serves as an example on how to integrate the spell checker library with a minimum of coding effort. To integrate the spell checker, you will need to1) implement four procedures in each window for which you want to enable spell checking. Take care to name the procedures correctly. The procedures are as follows
CanSpellWindow () OMNIS Classic
$canspellwindow () OMNIS Studiothis procedure should return kTrue if the window can be spell checked.
See example libraries for code examples.
CanSpellField ( pField, pIsCheckWindow ) OMNIS Classic
$canspellfield (pField, pIsCheckWindow ) OMNIS Studioparameter pField is the item reference of the window field. The procedure should return kTrue if the specified field can be spell checked. The pIsCheckWindow parameter is true if CanSpellField is called because of a check window option.
See example libraries for code examples.
GetSpellData( pField, pData, pFirstSel, pLastSel, pUserRef ) OMNIS Classic
$getspelldata( pField, pData, pFirstSel, pLastSel, pUserRef ) OMNIS Studiothis procedure is responsible for returning the data of the specified field for checking. As well as the data, it must also return the current selection in pFirstSel and pLastSel, if applicable. Note that pFirstSel and pLastSel do not specify character positions, but indicate the cursor positions, i.e. a position of 0 (zero) indicates the selection starts add the beginning of the text. For example, if the first word in an edit field was selected, and it was 5 characters long, pFirstSel would be 0 and pLastSel would be 5.
The parameter pUserRef is for your use. It can be used in special circumstances, i.e. checking a list field. When checking a list field you could return in it the column and row number of the data. The value will not be used by the spell checker, but is passed to SetSpellData, so the corrected text can be placed in the correct cell of the list.
See example libraries for code examples.
SetSpellData ( pField, pData, pFirstSel, pLastSel, pUserRef ) OMNIS Classic
$setspelldata ( pField, pData, pFirstSel, pLastSel, pUserRef ) OMNIS Studiothis procedure is responsible for assigning the corrected data to the field. If it is a data bound field, the procedure should both update the contents of the field and the data name. If the field supports selection, it should also update the selection. The selection as specified by pFirstSel and pLastSel are not character positions, but indicate the cursor positions, i.e. a position of 0 (zero) indicates the selection starts add the beginning of the text. The parameter pUserRef is a long integer which can be used by you to communicate special situations between GetSpellData and SetSpellData. For example if you were checking a list on a window you could use pUserRef to encode the current row and column of the data being checked. If there is more data to be checked, after the current data, which you are returning, has been checked, you should return a value of kTrue from this procedure. Otherwise you should return kFalse.
See example libraries for code examples.
ReplaceHandler () ACWrite in OMNIS Classic only
this procedure is responsible for replacing corrected text in an ACWrite external area as it is being checked. Unless you want to spell check ACWrite documents, you will not need to implement this procedure. Standard OMNIS text fields only contain raw text. When we check these fields, we give the raw text to the spell checker, and when the corrected text is returned, the contents of the field are simply replaced. This can not be done with ACWrite, since all formatting information would be lost. Instead we retrieve the raw text from ACWrite and pass it to the spell checker engine for checking. At the same time we call SPLLsetReplaceHandler telling the spell checker to call our procedure when text is being replaced. When our replace handler is called, we can call SPLLgetReplaceInfo to get the start and end range of the text to be replaced together with the text which replaces it. The text being replaced should be in small enough chunks so that the formatting information is not disturbed.
See example libraries for ACWrite code examples. NOTE: You will require the Classic version of ACWrite to run this example.
2) implement the following code in the window control procedures of each window for which you want to enable spell checking.
If #TOTOP
Call procedure spell.mSpell/WindowChanged ($cwind)
Else If #CLOSE|#WCLICK
Call procedure spell.mSpell/WindowChanged (#NULL)
Else If #BEFORE
Call procedure spell.mSpell/FieldChanged ($cobj().$ref)
Else If #AFTER
Call procedure pell.mSpell/FieldChanged (#NULL)
End If
3) open the spell checker library and install the menu mSpell. You should do this in your STARTUP procedure of your library. For example
Open library (Do not close others) {spell.lbr}
Install menu spell.mSpell
The example library also contains an example on how to check several records of data in one session. See procedure STARTUP.Check all Records.
WARNING: The spell checker window wSpell uses a timer procedure in order to set the focus to the edit field that shows the sentence being checked. This was the only reliable way to set the focus to this field when nested enter data commands are on the procedure stack. If your library uses a timer procedure for some other tasks, you will need to make some changes to the windows code. The procedure which sets the timer procedure is called EnterData. The timer procedure is set immediately before the Enter Data command is executed. The first time the timer procedure is executed, it clears it self and sets the current field.
.