Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to use sys(1500)

Status
Not open for further replies.

ajpa

Programmer
Jan 31, 2002
52
GB
I'd like users to be able to spell check some text they've entered (that will eventually be stored in a memo field). I rather hoped that

x=SYS(1500,"_MTL_SPELL","_MSYSMENU")

might do the trick, but it doesn't. Part of the problem, I suppose, is that by the time one presses the button to activate this line of code, the cursor is no longer in the edit box, and if I issue thisform.Edit1.SetFocus the command is by then dead.

The thing is that I don't really want to put the menu bar on the form, but maybe I'll have to.

Is there some other simple way of accessing FoxPro's internal spell checker?

Tony Ayres
 
You can use Word's dictionary. Try the following code...

Brian

lcString = "Spell correcty with a dictionory"

loWord = CreateObject("Word.Application")
loWord.Documents.Add()

lcCorrect = loWord.CheckSpelling(lcString)
?lcCorrect && if .f. then there's a spelling problem

IF lcCorrect =.f.
FOR lnWordCnt = 1 TO ALINES(SpellArray,lcString ," ")

lcWord = SpellArray(lnWordCnt)
?"Word Being Checked: "+lcWord
loSuggestions = loWord.GetSpellingSuggestions(lcWord)
FOR EACH loSuggestion in loSuggestions
?"Correction suggested: "+loSuggestion.Name+;
" in place of "+lcWord
ENDFOR
ENDFOR
ENDIF

loWord.quit
loWord=.null.
 
From the Microsoft Website - "While Visual FoxPro includes its own spell checking (in the form of SPELLCHK.APP), this component cannot be redistributed."

You will see that the spellchk.app is not in the list of redistributable files in redist.txt

MODIFY COMMAND (HOME() + "redist.txt")

Perhaps you are using a different spell checking program (unlikely but possible)? You can check by looking at the _Spellchk system variable:

?_Spellchk

Other solutions you may wish to consider in light of the preceding:

Word SpellChecker Example
faq184-4258

Word SpellChecker example (Version 2)
faq184-4292


Slighthaze = NULL
craig1442@mchsi.com
"Whom computers would destroy, they must first drive mad." - Anon​
 
Ajpa,

. Part of the problem, I suppose, is that by the time one presses the button to activate this line of code, the cursor is no longer in the edit box

Actually, that's not completely true. If you execute the code from a menu command or a toolbar button, focus will still be in the edit box. The problem will only arise if you execute the command from another control, on the same form or another form.

As Slighthaze rightly say, the spell checker that comes with VFP cannot be redistrubed, so you cannot call it from within your application at the user's site. But there is nothing to stop you doing what you want to do if you are in the VFP development environment.

For an alternative approach to spell checking, take a look at the article by Alan Fleet at
Mike


Mike Lewis
Edinburgh, Scotland
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top