Thankyou for your replies. Those functions are pretty cool mmerlinn, nice work.
I still have much to work on with this, and it looks like I will probably redesign the concept a bit until I get a good result.
What I am trying to achieve is to replace the visual portion of MSWord spell checker with a VFP one. The reason being, that in most cases, the msword spell check dialog does appear correctly in front of VFP, but sometimes it does not and the user has to click on the word icon in the task bar to bring it to front.
While most users learn this, occassionaly they have "Moments", where I can see their frustation and desk thumping with the comments "What's wrong with your program?"
So I if MSWord encounters spelling mistakes, I can generate a list of the mis-spelt words with:
Code:
FOR EACH loError IN loDoc.SpellingErrors
lcWord=loError.Text
lnWordID=lnWordID+1
DIMENSION this.spellingerrorlist(lnWordID ,3)
STORE lnWordID TO this.spellingerrorlist(lnWordID, 1) && count
STORE lcWord TO this.spellingerrorlist(lnWordID, 2) && error
STORE lcWord TO this.spellingerrorlist(lnWordID, 3) && word to replace with, for now, it is the error
ENDFOR
For each mispelt word I can get a list of suggestions with:
Code:
loSuggestions = oWrd.GetSpellingSuggestions(lcWord)
lnCount = loSuggestions.count
IF lnCount = 0
&& if there are no suggestions, add this dummy line
lnSuggestID = lnSuggestID+1
DIMENSION this.spellingsuggestionlist(lnSuggestID ,2)
STORE 0 TO this.spellingsuggestionlist(lnSuggestID , 1) && 0
STORE "No Suggestions" TO this.spellingsuggestionlist(lnSuggestID , 2) && No words
ENDIF
For each loSuggestion In loSuggestions
lnSuggestID = lnSuggestID+1
lcSuggest= loSuggestion.Name
DIMENSION this.spellingsuggestionlist(lnSuggestID ,2)
STORE lnSuggestID TO this.spellingsuggestionlist(lnSuggestID , 1)&& suggestion id
STORE lcSuggest TO this.spellingsuggestionlist(lnSuggestID , 2) && suggested word
EndFor
So I already have the list of spelling errors, then I have to step through the string in VFP visually for the user to interact with.
To achieve this, I SET MEMOWIDTH TO 60 and then display a few lines at a time and as each word is dealt with, until the end of the string.
That is why I was exiting the nested loops as I needed to get the next word in the list previously created.
I also learned that I had to strip certain characters from the string, like commas and fullstops as VFP would not always find the word identified by msword.
However, I think I will perhaps to do this another way . . .
Send the entire text to word to get an error count. If > 0, then continue otherwise quit
Then clear the entire text from MSword and send a line at a time to msword, if no errors are found, keep clearing the text and sending the next line until errors are found.
If errors are found on the line, step through the line a word at a time getting the match ups between the string and msword errors & get the user to do their corrections before continue looping through the lines. The purpose of identifying the number of character left of the specfic word was so I could accuratly place a visual indicator to identify the current word with the spelling mistake.