Lightening


User wish to have this function. Is this possible Thanks.


Re: Any way to introduce spelling check into VFP?

dni


You may spell check with word help:

http://support.microsoft.com/kb/271819







Re: Any way to introduce spelling check into VFP?

Naomi Nosonovsky

You may check http://www.sweetpotatosoftware.com/SPSBlog/SearchView.aspx q=spellcheck

Another way would be using Word automation and its build in Spell Check.

I also think there are classes for Spell check on for-profit web site in Downloads section.






Re: Any way to introduce spelling check into VFP?

Naomi Nosonovsky

In addition to my reply simply search fox.wikis.com on SpellCheck and there are several good links, for instance:

http://fox.wikis.com/wc.dll Wiki~Spellchecker





Re: Any way to introduce spelling check into VFP?

Lightening

Thank you all for your replies. One of them should work. I will keep you posted.





Re: Any way to introduce spelling check into VFP?

Naomi Nosonovsky

So, did you choose Word Automation



Re: Any way to introduce spelling check into VFP?

Lightening

Hi, Naomi,

I like dni's option. It appears to be simple. But I do not know how to replace the form1 with my own form and check an Edit box.

http://support.microsoft.com/kb/271819

I am still a VFP newbie though played it for a while.





Re: Any way to introduce spelling check into VFP?

Naomi Nosonovsky

This option relies on Word being installed and being associated with .DOC files. I think this is quite a safe assumption, but just want to point out few limitations of this method.

Now, if you already have form designed and now you want it to be based on your own class, which you have in your classlibrary, you need to open this form in Class Browser (called from Tools menu) and right click on the form. One of the menu choices would be redefine, in this dialog you can point to your form's class.

To change class for the Editbox, unfortunately, there is no direct simple method. The method I use in such cases is direct hacking of scx file (since it's a table).

1. Back up your form - very important.

2. Use YourForm.scx

browse for 'myeditbox' $ lower(objname)

manually replace class and classloc fields with the name of your editbox class (in lower case) and name of your library (in lower case).

USE

Try to run the form now. If you have problems, it means, you've done something wrong and now you have to restore this form from the backup.





Re: Any way to introduce spelling check into VFP?

Lightening

Thank you, Naomi,

But how to create the class based on that piece of code





Re: Any way to introduce spelling check into VFP?

Naomi Nosonovsky

Sorry for answering with a link to the other thread in this forum, but I think you may start with this http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1576069&SiteID=1 Use Craig's Boyd excellent videos, they should get you up to speed with VFP.



Re: Any way to introduce spelling check into VFP?

Lightening

Thank you. Pretty good video. I will spend a bit more time on it.



Re: Any way to introduce spelling check into VFP?

Lightening

I modified the code into a function as follows: Not sure I made it better or worse. Pls advise.

In each of my forms, I added a Spellchecking method and put codes to call the following function:

=CheckSpell("Edit1", Alltrim(ThisForm.Edit1.Value)

ThisForm.Edit1.Value=m.cCorrectString

Code Snippet

Function CheckSpell && Spell Checking function for some Edit boxes
Para cEdit, cValue

Public cCorrectString
cCorrectString=""
cEditBox = cEdit

m.Err = .F.
On Error m.Err=.T.
WordApp=CREATEOBJECT("Word.application")
**--------------------------------------------------------
IF m.err = .t. && Check if you have already instantiated Word
MESSAGEBOX([Microsoft Word is either not installed or is incorrectly registered.], + ;
0,[Word Start-Up Failed])
RETURN .F.

*!* Change the mouse pointer for all form controls to indicate processing (opening Word)
WITH THISFORM
.cEditbox.MOUSEPOINTER = 11
.cEditBox.MOUSEPOINTER = 11
.MOUSEPOINTER = 11
ENDWITH
Else
PUBLIC goWord, goWordDoc && Public vars for Word and Document1 in Word.
goWord = CREATEOBJECT([WORD.APPLICATION]) && Create Word
WITH goWord
.WINDOWSTATE= 0 && wdWindowStateNormal (needs to be Normal before you can move it)
.MOVE(1000,1000) && Move the window out of view
goWordDoc = .Documents.ADD
ENDWITH

*!* Change mouse pointers back
WITH THISFORM
.cEditBox.MOUSEPOINTER = 0
.cEditBox.MOUSEPOINTER = 0
.MOUSEPOINTER = 0
ENDWITH

ENDIF

WITH goWordDoc
.Content.TEXT = cValue
.ACTIVATE
IF .SpellingErrors.COUNT > 0
.CHECKSPELLING
ELSE
=MESSAGEBOX([Spell check complete. No errors found],0,[Spell Check])
ENDIF
*!* For some reason, Word likes to make itself visible here. Keep it hidden...
goWord.VISIBLE = .F.
m.cCorrectString=allt(.Content.Text)
ENDWITH
Return m.cCorrectString





Re: Any way to introduce spelling check into VFP?

Naomi Nosonovsky

What is your VFP version If it's VFP8 or above I would advise you to use TRY/CATCH block instead of ON ERROR, since, for instance, you're not restoring it if you return .f.

You also don't check for what you're returning.

These are two things that jumped immediatelly after the quick glance at the code. I may review your code later at home more throroughly.

I would also really recommend to take a look at Craig Boyd's fll. This way you don't depend on Word being installed.





Re: Any way to introduce spelling check into VFP?

Lightening

Still using VFP6. Good advice. I will try that under a higher version. For the returning value, I hesitate to do that.

If user make changes, that what he/she expects. If not, there is no harm to replace it again. But if he deleted (accidentally)

some words, it is hard to find.





Re: Any way to introduce spelling check into VFP?

Naomi Nosonovsky

I mean that in some cases you're returning .F. while obviously you expect to return a character value.

Also you can not use thisform reference inside the program, only in form's methods. If you want to manipulate with the form inside the program you can either pass form's reference to the program (e.g.

lcNewString = MySpell(parm1,parm2, thisform)

or use _screen.ActiveForm instead of thisform (but then you would need to check if you have an active form).