*PLUS/SPELL/SPELL |
Spell Checker Interface |
PxPlus now includes a spell checker interface that provides the ability to add spell checking to input fields using either popup menus or through other application coding. The interface is designed to utilize the spell checker engine Ispell or its follow along product Aspell. These utilities are already installed with most Linux systems. Versions are also available for Windows and most other systems.
(The Spell Checker interface was added in PxPlus v8.11, build 9182.)
In addition, PxPlus provides an AutoSpellCheck option that is used to set automatic spell checking for Multi-Line controls.
(The AutoSpellCheck option was added in PxPlus 2019.)
For the spell checker to function, it needs to know the location of the spell checker engine and the language to use. Two global variables are used for this:
%SPELL_SITE$ |
This variable contains the Internet URL (http/https string) to a Web site that will provide Internet base spell checking or a pipe symbol ( | ) followed by the pathname and arguments required to run the spell checker directly on your machine. To handle different languages, the system will automatically replace "@@" with the two character language code being used. Typical Internet setting would be: %SPELL_SITE$="https://www.pvxplus.com/cgi-bin/aspell.cgi" Note:
|
%SPELL_LANG$ |
This variable should contain the default two-character language code to use in lower case. If not set, the system will look at the current NOMADS library pathname, and if its suffix is two characters long, this will be used. Otherwise, it will default to "en" for English. The language code should be one of to the international standard language codes. At this time, the spell checker includes end user screens for the following: English (en), French (fr), Spanish (es), German (de) and Dutch (nl). |
Adding to an Individual Control
To use the spell checker in any application, you will first have to set %SPELL_SITE$ to identify where the spell checker itself resides and optionally define the language to use in %SPELL_LANG$. Once these have been defined, within NOMADS you can use a popup_menu to add the spell checker to any input field.
To use, attach a popup menu to the control you want to have the spell checking capabilities then add a menu item that will issue a PERFORM of "*plus/spell/spell".
Adding to All Inputs in a NOMADS Application
You can also have the system automatically add the spell checker to all unformatted input fields (Multi-lines). Two additional global variables are used to control this functionality:
%SPELL_POPUP$ |
This variable defines the Popup menu text to add to all input fields. It should contain an & (ampersand) to identify the letter the user can select from the popup menu. All Multi-lines will have this popup menu selection added to them. Example: %SPELL_POPUP$="&Spell Check text" |
%SPELL_MIN_LEN |
This variable defines the length of smallest unformatted Multi-line to which spell check will be added. Multi-lines whose input length (or size) is smaller than the value defined in this variable will not have the spell checker added. Formatted inputs will not have the spell checker added to them whereas input fields that allow for multiple lines of input will. Setting this variable to 1 will effectively add the spell checker to all unformatted inputs. |
Directly Invoking the Spell Checker
If desired, the spell checker can be called directly from your application to check the spelling of a text field. This is done by issuing a call to "*plus/spell/spell" where you can pass the control to check or the text to check/change.
Calling Sequence:
CALL "*plus/spell/spell", ctl_id, langcode$, text$, spell_url$
Where:
ctl_id |
If non-zero, it provides the input control that contains the text to spell check. If 0 (zero), then the text to check will be passed in the TEXT$ field. |
langcode$ |
Language code to use. If a null string is passed, the current setting as defined by %SPELL_LANG$ is used. |
text$ |
String contains the text to check/change if ctl_id is 0 (zero). If ctl_id is non-zero, this field is ignored. |
spell_url$ |
If non-blank, string will contain the URL that will override %SPELL_SITE$. |
By default, the spell checker is enabled within NOMADS and the Integrated Toolkit (*IT) to provide the developer with spell checking during application development.
If %SPELL_SITE$ is not set, the built-in interface uses the Internet to validate spelling on a secure PVX Plus Technologies Web site.
Using a Web site to host the spell checker software makes installation and on-going dictionary updates much easier to handle. This can be done using a small 'CGI' script and the Apache Web server.
To create an Aspell Web site to provide spell checking, install and setup your Apache server, then create the following CGI script:
#!/bin/bash
echo Content-type: text/plain
echo ''
aspell -a | grep ' '
This will run Aspell with whatever text is submitted with the Web request and will work with the *plus/spell/spell module as provided. This can be hosted as either a secure (https: //) or unsecured (http://) Web site.