Before beginning, some preliminary notes
First, no case is implied that FMPro is better than other database-creation programs. One grows with the software that in most cases one has come to use by circumstantial exposure (for example, at the place of work) rather than by consciously weighing up the specifications of all the available products, trialling them and then choosing the most suitable. Among the many competitive products there isn’t one that inarguably stands out as the best: all products can manipulate data sufficiently well to be able to provide solutions to everyday data tracking problems.
Second, the ability to create a grammar checker is not a recommendation that one should reinvent the wheel but rather that the ideas used in the demonstration can be applied to projects of lesser scale; for example, programmers may develop correcting modules to oversee input in text fields (more of that later).
Third, grammar checkers are rules-based and programmers require an understanding of the rules of sentence structuring, especially the role parts of speech (noun, verb, adjective, adverb, and so on) play.
Finally, steps 1 to 12 will give immediate results with FMPro opened in front of you; steps beyond 12 will provide instructions for creating a real-world grammar checker in FMPro Advanced.
1. Open FMPro, click File, New Database. Name the new file “Grammar Checker Demonstration” and click Save.
2. In the Define Database window, you are presented with the Field tab. Three fields will be created for the demonstration: one for users to enter text, another for grammar feedback and the last one for metadata.
3. Where the cursor is flashing, enter the field name, “Comment”, and click Create. Its type is as given, “Text”.
4. Enter the second field name, “Feedback”, and select from the “Type” drop-down list, “Calculation”. When the Specify Calculation window appears select “Text” for the box with the label “Calculation result is” and click OK (at this stage no calculation will be written; this will be done later) and click Create.
5. The third field name is Metadata; it too has “Calculation” as its type, and its calculation result is “Text”. No code is entered as yet. (For our purpose, “metadata” may be understood simply to mean additional information about data).
6. When all three fields have been defined, click OK.
7. You are now automatically presented with a basic layout. Leave as is. This is your database for the demonstration.
8. The Text field is ready to go, but the Feedback field will be depended on the Metadata field and the Metadata field will be depended on FMPro’s built-in Substitute function.
9. We now go back to redefining the third field, Metadata. Click File, Define, Database. Select the Metadata field and click Options. In the Specify Calculation window, look for the Substitute function from the list of built-in functions located top right. When found, double-click it and it now appears in the editing area. Highlight the “text” parameter only and from the list of fields, top left, double-click the Comment field. This points the Substitute function to the contents of the Comment field. Highlight the second parameter, searchString, and type between quotation marks: cats. Highlight the third parameter, replaceString, and type between quotes, np, which stands for “noun plural”. Enclose this pair in square brackets and type a semi-colon after the closing square bracket. Between a new pair of square brackets, repeat same procedure for “has” and “vas” (verb auxiliary singular), within another pair of square brackets “four” and “as” (adjective singular) and within the final pair of square brackets “legs” and “np”. Your Substitute function should like this: Substitute ( Comment ; [“cats” ; “np”] ; [“has” ; “vas”] ; [“four” ; “as”] ; [“legs” ; “np”] ). Click OK twice. For the purpose of demonstration, the Metadata field is complete. The field has been programmed to copy the contents of the Comment field and to translate each word with its designated part of speech.
10. If not in Browse mode, switch to Browse mode and enter the following in the Comment field exactly as is (do not capitalise nor correct the obvious grammar error): “cats has four legs”. Click anywhere outside the field to update FMPro. In the Metadata field appears: “np vas as np”. The words in the Comment field have been generalised with their attribute as parts of speech. The actual words no longer matter. That’s why the next thing we do is go back to the Feedback field and give it references to the Metadata field, totally ignoring the Comment field.
11. For the purpose of demonstration, the Comment field and now the Metadata field are ready to go. Our attention will presently focus on the Feedback field. Click File, Define, Database. Highlight the Feedback field and click Options. The Feedback field will be programmed to recognise patterns in the Metadata field that may be grammatically questionable and then alert the user. To do this, we will use two other FMPro built-in functions: Case and PatternCount. There will be one Case function and one PatternCount for the purpose of the demonstration. Find the Case function in the list of functions (top right), double-click it, highlight test1 and find PatternCount in the function list and double-click it. Highlight its “text” parameter and double-click the field, Metadata, from the list of fields top left. Highlight searchString and type between quotation marks: np vas. Highlight all the other parameter and type between quotation marks: A plural noun has been followed by a singular auxiliary verb; perhaps change one or the other to match. At the end of this programming snippet your editing area should like this: Case ( PatternCount ( Metadata ; “np vas” ) ; “A plural noun has been followed by a singular auxiliary verb. Perhaps change one or the other to match” ). The Case function has been empowered, via the PatternCount function, to test if a certain questionable pattern exists in the contents of the Metadata field, and if a certain questionable pattern is found to then give a message to alert the user to the nature of the issue.
12. Click anywhere outside the field and, presto, the alert message is given. To test that this works, change “cats” to “cat” in the Comment field, click outside the field and instantly the message disappears. Put the “s” back, click outside the field and the message reappears. What we have done is demonstrate how a grammar checker works and that it is possible to create one in FMPro. What we have not shown, however, is a real-world grammar-checker module that oversees up to a million words. FileMaker Pro 8 will no longer do as we need to use a new programming window called Custom Functions and this is only available in FileMaker Pro 8 Advanced.
13. The layout has to be modified. Switch to Layout mode and make the Comment field much larger and add a scroll bar (with the field selected in Layout mode, click Format, Field/Control, Setup and check “Include vertical scroll bar”). Make the Feedback large enough to fit the possible messages. The Metadata field will be placed on a newly created layout and hidden from the user. Do all other design work to make your database congenial for use by others.