Using the Spellcheck Object

From FusionWiki

Jump to: navigation, search

Originally posted by Jax -

Contents

Stage 1: Load a dictionary

Obviously the spell-checker doesn't work without a dictionary. Insert the object into the frame and don't change anything on the dialog box. Most of these settings are only required for advanced use.

Now, 'On start of frame' you want to ' Load Wordlist (Pauses MMF) '. For more advanced use you can load it in the background and update a progress bar using ' LoadingPercentage ' expression, but for now we'll just let it pause your program whilst it is loading.

Choose ' Smaller Wordlist.nswl ' as the dictionary, which you can download from here.

'NSWL' stands for 'Null separated word list'. This means that each word in the dictionary is separated by a 'null character'. (ASCII value 0). Words can also be separated by new lines, but as a new line in Windows is 2 characters using null characters saves a little bit of space.

It is also OK to load one dictionary then another, and the object will then have a dictionary with both the details.

All Spellcheck objects share the same dictionary, so if you load it on the first frame and use it again on the second, you don't need to reload it.

Now we can't actually tell if it has worked so far when we run it, so we need to continue...

Stage 2: Checking if a word is in the dictionary

We can check if a word is in the dictionary by using the '[i]Is Word correct?[/i]' condition. So, let us make an edit box with a button which tells us what is the case.

Add a button and an edit box, and add the condition "On Button Clicked" + "Is [Text of edit box] correct?" and provide some effect, like setting a string to "Is in dictionary". Then have the same event but with the second condition negated and have it do something like set a string to "Is not in dictionary". The following screen-shot shows this:

http://sites.google.com/site/jlnwebster/misc-files/Spellcheck004.png

We can test that the spell check really does use the same dictionary for each object by doing the loading and the checking in different frames.

Stage 3: Getting suggestions

Now this is not very exciting. However, we can get suggestions using the object. To do this, you get the incorrectly spelled word and pass it to " List Suggestions " action. This doesn't directly do anything, but it does cause the 'On Correction Suggestion' event to get triggered once per suggestions.

So add a list box, and when an incorrect word is found you should clear it and then call 'List suggestions', adding the suggestion to the list each time. Use 'Suggestions -> Get Suggestions' (Suggestion$) to get the name of the current suggestion.

Tweak the settings on the dialog box to change how the results are returned.

The Next Step

The next step is to spell-check sentences. This means splitting it up into words. This is such an annoying, boring, repetitive task that it'd be useful if it does it for you. So it does! That is what the 'Auto-parse' setting does - read the docs for it. It even allows you to set things that it does and does not spell check inside, so you can really easily make something that only spellchecks things in quotes or within comments in a programming language, for instance.

Does this help?

Documentation/Examples

Here is a copy of the original documentation and examples.

At least the major example loads. The extra ones (which I seem to recall shows spellchecking HTML) require the scrollbar object, so I guess you could do that trick for making things load when an extension is missing.

Personal tools