InfoConnect for Unisys
Attachmate.Reflection.Productivity Namespace / ISpellCheck Interface / CorrectMisspelling Method
The misspelled word.
The correctly spelled word which replaces the misspelled word.
Example


In This Topic
    CorrectMisspelling Method
    In This Topic
    Replaces a misspelled word with a correction at the specified location.
    Syntax
    'Declaration
     
    
    Sub CorrectMisspelling( _
       ByVal misspelled As MisspelledWord, _
       ByVal correction As String _
    ) 
    'Usage
     
    
    Dim instance As ISpellCheck
    Dim misspelled As MisspelledWord
    Dim correction As String
     
    instance.CorrectMisspelling(misspelled, correction)
    void CorrectMisspelling( 
       MisspelledWord misspelled,
       string correction
    )

    Parameters

    misspelled
    The misspelled word.
    correction
    The correctly spelled word which replaces the misspelled word.
    Exceptions
    ExceptionDescription
    Thrown if either of the input arguments are null (or in Visual Basic are Nothing).
    Thrown if the correction string parameter is zero-length (empty).
    Example
    using System;
    using System.Drawing;
    using System.Collections.Generic;
    using System.Text;
    using Attachmate.Reflection.Framework;
    using Attachmate.Reflection.Emulation.IbmHosts;
    using Attachmate.Reflection.UserInterface;
    using Attachmate.Reflection.Productivity;
    
    namespace ChangingThemes
    {
        class Program
        {
    
    
            static void Main(string[] args)
            {
                //Start a visible instance of InfoConnect or get the instance running at the given channel name
                Application app = MyReflection.CreateApplication("myWorkspace", true);
    
                //Create a terminal from the session document file
                string sessionPath = Environment.GetEnvironmentVariable("USERPROFILE") + @"\Documents\Micro Focus\InfoConnect\demoSession.rd3x";
                IIbmTerminal terminal = (IIbmTerminal)app.CreateControl(sessionPath);
    
                //Make the session visible in the workspace
                IFrame frame = (IFrame)app.GetObject("Frame");
                frame.CreateView(terminal);
    
                IIbmScreen screen = terminal.Screen;
    
                IProductivity productivityTools = terminal.Productivity;
    
                ISpellCheck spelling = terminal.Productivity.SpellCheck;
    
                //enable SpellCheck
                spelling.Enabled = true;
    
                spelling.MainLanguage = SpellingLanguage.EnglishUS;
    
    
                //Set the maximum number of spelling suggestions for a misspelled word. 
                spelling.MaxSuggestions = 9;
    
                //Set the minimum length of fields reviewed for spelling errors.
                spelling.MinimumMatch = 5;
    
                //Specify a custom dictionary
                spelling.CustomDictionaryPath = Environment.GetEnvironmentVariable("USERPROFILE") + @"\Documents\Micro Focus\InfoConnect\customDictionary.tlx";
    
                //Add a word to the active custom dictionary. 
                //The setting has no effect if a custom dictionary isn't specified. 
                //After a word is added to the custom dictionary, it is no longer considered as being misspelled.
                spelling.AddToCustomDictionary("nrmlywrng");
    
                
                
                //Correct a word that begins with a lowercase letter and is followed by all uppercase letters
                spelling.CorrectAccidentalCapsLock = true;
    
                //Correct a word that begins with two or more uppercase letters 
                //to a word that begins with a single uppercase letter. 
                spelling.CorrectTwoInitialCaps = true;
    
                //exclude words that contain numerals from a spelling review
                spelling.IgnoreWordsWithNumbers = true;
    
                //exclude words that use only uppercase letters from a spelling review. 
                spelling.IgnoreAllUppercase = true;
    
                //Automatically reviews words for spelling errors as they are typed, 
                //adding wavy red lines under possibly misspelled words
                spelling.CheckSpellingAsType = true;
    
                //automatically correct spelling mistakes as they are typed,
                //provided that Auto Correct suggestions for the misspelled word are available.
                spelling.AutoCorrect = true;
    
                screen.BeforeSendControlKey += screen_BeforeSendControlKey;
    
    
                Console.ReadLine();
            }
    
            static void screen_BeforeSendControlKey(object sender, BeforeSendControlKeyEventArgs args)
            {
                IIbmScreen screen = (IIbmScreen)sender;
                ISpellCheck spelling = screen.Parent.Productivity.SpellCheck;
    
                //Spell check the current screen
                spelling.CheckScreen();
    
                Console.WriteLine("in event");
    
    
    
                MisspelledWord[] words = spelling.MisspelledWordCollection;
    
                foreach (MisspelledWord word in words)
                {
                    Console.WriteLine(word.Word);
                    if (word.Word == "PartNo") 
                    {
                        Console.WriteLine("removing");
                        //Removing is not working
                        //Removes the specified misspelled word from the misspelled word list and
                        //clears the associated misspelling attribute from the screen.
                        //spelling.RemoveMisspelling(word);
    
    
    
                        //Replaces a misspelled word with a correctly spelled word at the specified location.
                        spelling.CorrectMisspelling(word, "Part Number");
    
                    }
                    
                }
    
                //Clear all misspellings from the current screen.
                spelling.RemoveAllMisspellings();
            }
    
    
    
        }
    }
    
    
    
    
    
    
    
    
    
    
    See Also