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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Spell Check

Status
Not open for further replies.

tigress

Programmer
Jul 2, 2002
5
US
Can someone recommend a good tool, utility or method for spell checking a column that is a varchar(5000)? I found the example for using Excel, but it is limited to 255.

Thanks
 
We use one Called Sentry Spell Checker - distributed as .DLL and very easy to implement - been using it for several years now, so our version's probably a bit out of date. See
We've implemented a user object with one function:

public function string uof_spellcheck (string instring)

takes string argument to be checked returns checked / corrected string.

A PB 6.5 Export of nvo :

$PBExportHeader$uo_spell_check.sru
forward
global type uo_spell_check from nonvisualobject
end type
end forward

global type uo_spell_check from nonvisualobject
end type
global uo_spell_check uo_spell_check

type prototypes
FUNCTION long SSCE_CheckBlockDlg(int Whatwin, REF string thistest, long oldlength, long newlength, int showcontext) LIBRARY "SSCE5232.DLL"
FUNCTION long SSCE_SetMainLexPath(string Pathvar) LIBRARY "SSCE5232.DLL"
FUNCTION long SSCE_SetUserLexPath(string Pathvar) LIBRARY "SSCE5232.DLL"
FUNCTION long SSCE_SetMainLexFiles(string Pathvar) LIBRARY "SSCE5232.DLL"
FUNCTION long SSCE_GetMainLexFiles( REF string LexFiles, long length ) LIBRARY "SSCE5232.DLL"
SUBROUTINE SSCE_ResetLex() LIBRARY "SSCE5232.DLL"
end prototypes

forward prototypes
public function string uof_spellcheck (string instring)
end prototypes

public function string uof_spellcheck (string instring);int retval,blklen,newlen
string block,outstring

string ls_MainLexPath, ls_UserLexPath, ls_LexFiles, ls_FullPath

// has the effect of ensuring the spellcheck DLL is loaded
if NOT gb_spell_lib_loaded then
SSCE_ResetLex()
gb_spell_lib_loaded = true
end if

block = Instring
blklen = Len(block)

block = block + space(blklen/5)

ls_UserLexPath = g_nv_ini.fnv_profile_string( "SSCE", "UserLexPath", "none" )
if ls_UserLexPath <> &quot;none&quot; then SSCE_SetUserLexPath( ls_UserLexPath )

ls_MainLexPath = g_nv_ini.fnv_profile_string( &quot;SSCE&quot;, &quot;MainLexPath&quot;, &quot;none&quot; )
ls_LexFiles = space(128)
SSCE_GetMainLexFiles( ls_LexFiles, 128 )
if pos( upper( ls_LexFiles ), 'SSCEBR' ) = 0 then
if ls_MainLexPath <> &quot;none&quot; then
SSCE_SetMainLexPath( ls_MainLexPath )
ls_FullPath = ls_MainLexPath
if right( ls_MainLexPath, 1 ) <> &quot;\&quot; then ls_FullPath += &quot;\&quot;
if NOT FileExists( ls_FullPath + &quot;sscebr.lex&quot; ) then
MessageBox( &quot;Error&quot;, &quot;File SSCEBR.LEX not found in directory &quot; + ls_MainLexPath + &quot;~nSpell checker will not work properly.&quot; )
else
SSCE_SetMainLexFiles( &quot;sscebr.lex&quot; )
end if
else
MessageBox( &quot;Error&quot;, &quot;ini file entry [SSCE] MainLexPath is missing.~nCannot assign main lexical files.&quot; )
end if
elseif ls_MainLexPath <> &quot;none&quot; then
ls_FullPath = ls_MainLexPath
if right( ls_MainLexPath, 1 ) <> &quot;\&quot; then ls_FullPath += &quot;\&quot;
if NOT FileExists( ls_FullPath + &quot;sscebr.lex&quot; ) then
MessageBox( &quot;Error&quot;, &quot;File SSCEBR.LEX not found in directory &quot; + ls_MainLexPath + &quot;~nSpell checker will not work properly.&quot; )
end if
end if

newlen = SSCE_CheckBlockDlg(0,block,blklen,len(block), 1)

if newLen > 0 then
outstring = left(block,newlen)
return outstring
else
return Instring
end if

end function
on uo_spell_check.create
TriggerEvent( this, &quot;constructor&quot; )
end on

on uo_spell_check.destroy
TriggerEvent( this, &quot;destructor&quot; )
end on
 
I found the following thread on a Powerbuilder forum from back in 1999.

- Matt

<message below>

Message 1 in thread
From: eric chung (saifaic@hkstar.com)
Subject: spell check with MsWord, not Excel
Newsgroups: powersoft.public.powerbuilder.ole-ocx-activex
View this article only
Date: 1999/03/01


Hi all,
I use multiLineEdit to contain the text what I typed and I want to use
spellcheck function with MsWord to change the wrong spelling at
multiLineEdit without display word document. Is there any samples ?
thanks a lot.

Eric
Message 2 in thread
From: Ajomon Joseph (ajoseph@sorosny.org)
Subject: Re: spell check with MsWord, not Excel
Newsgroups: powersoft.public.powerbuilder.ole-ocx-activex
View this article only
Date: 1999/05/11

Try this:
Note: You must have word in your machine. If it works replay.
/*====================================================================*/
string sDoc

If gs_current_text = &quot;&quot; then Return

/*place the text in clipboard from current column*/
If Clipboard(gs_current_text) = &quot;&quot; Then RETURN

//OleObject MyOleObject

MyOleObject = CREATE OLEObject

If MyOleObject.ConnectToNewObject(&quot;word.application&quot;) <> 0 Then Return

myoleobject.Application.Visible = False

myoleobject.Application.WindowState = 2

myoleobject.Application.Documents.Add.Content.Paste

myoleobject.Application.ActiveDocument.CheckSpelling

myoleobject.Application.ActiveDocument.Content.Copy

myoleobject.ActiveDocument.Close(0)


myoleobject.Application.Quit

MyOleObject.disconnectobject()

//Destroy Shared Variable OleObject
Destroy MyOleObject


messagebox(&quot;Information&quot;, &quot;The spelling and grammer check is complete.&quot;)

/*re-place the text in current column with text from clipboard */
gs_current_text = Clipboard()

/*====================================================================*/

eric chung wrote:

> Hi all,
> I use multiLineEdit to contain the text what I typed and I want to use
> spellcheck function with MsWord to change the wrong spelling at
> multiLineEdit without display word document. Is there any samples ?
> thanks a lot.
>
> Eric
Message 3 in thread
From: Oliver Willandsen [European Commission] (oliver.willandsen@PAS_DE_PUBsg.cec.be)
Subject: Re: spell check with MsWord, not Excel
Newsgroups: powersoft.public.powerbuilder.ole-ocx-activex
View this article only
Date: 1999/05/11


On Tue, 11 May 1999 10:10:01 -0400,
in powersoft.public.powerbuilder.ole-ocx-activex
Ajomon Joseph <ajoseph@sorosny.org> wrote:
>Try this:
>Note: You must have word in your machine. If it works replay.
>/*====================================================================*/
>string sDoc
>
>If gs_current_text = &quot;&quot; then Return
>
>/*place the text in clipboard from current column*/
>If Clipboard(gs_current_text) = &quot;&quot; Then RETURN
>
>//OleObject MyOleObject
>
>MyOleObject = CREATE OLEObject
>
>If MyOleObject.ConnectToNewObject(&quot;word.application&quot;) <> 0 Then Return
>
>myoleobject.Application.Visible = False
>
>myoleobject.Application.WindowState = 2
>
>myoleobject.Application.Documents.Add.Content.Paste
>
>myoleobject.Application.ActiveDocument.CheckSpelling
>
>myoleobject.Application.ActiveDocument.Content.Copy
>
>myoleobject.ActiveDocument.Close(0)
>
>
>myoleobject.Application.Quit
>
>MyOleObject.disconnectobject()
>
>//Destroy Shared Variable OleObject
>Destroy MyOleObject
>
>
>messagebox(&quot;Information&quot;, &quot;The spelling and grammer check is complete.&quot;)
>
>/*re-place the text in current column with text from clipboard */
>gs_current_text = Clipboard()
>
>/*====================================================================*/
>
>
>eric chung wrote:
>
>> Hi all,
>> I use multiLineEdit to contain the text what I typed and I want to use
>> spellcheck function with MsWord to change the wrong spelling at
>> multiLineEdit without display word document. Is there any samples ?
>> thanks a lot.
>>
>> Eric
>
Or alternatively, if you don't want to use the clipboard :

// public function boolean of_spellcheck (powerobject apo_spellcheckobject,
string as_language)

// replace 'This' with you_oleobject if you're not actually _in_ the
// oleobject !!

CHOOSE CASE apo_spellcheckobject.TypeOf( )

CASE datawindow!
ldw_sheet = apo_spellcheckobject
ls_oldtext = ldw_sheet.GetText( )

CASE multilineedit!
lmle_object = apo_spellcheckobject
ls_oldtext = lmle_object.Text

CASE singlelineedit!
lsle_object = apo_spellcheckobject
ls_oldtext = lsle_object.Text

CASE ELSE
MessageBox( &quot;ERREUR&quot;, &quot;This object can not be spellchecked&quot; )
RETURN FALSE

END CHOOSE

// create a new document
This.Application.Documents.Add ()


// insert text to be spell-checked
This.Selection.InsertAfter( ls_oldtext )


//Choose Case li_countrycode
// Case 1043
// Messagebox(&quot;Taal&quot;, &quot;Nederlands&quot;)
// Case 1036
// Messagebox(&quot;Langue&quot;, &quot;Français&quot;)
// Case 1031
// Messagebox(&quot;Sprache&quot;, &quot;Deutsch&quot;)
// Case 2057
// Messagebox(&quot;Language&quot;, &quot;UK English&quot;)
// Case 1033
// Messagebox(&quot;Language&quot;, &quot;US English&quot;)
// Case Else
// Messagebox(&quot;Language&quot;, &quot;Unknown&quot;)
//End Choose

CHOOSE CASE as_language
CASE 'DK'
This.Selection.LanguageId( 1030 )
CASE 'NL'
This.Selection.LanguageId( 1043 )
CASE 'EN'
This.Selection.LanguageId( 2057 )
CASE 'FI'
This.Selection.LanguageId( 1035 )
CASE 'FR'
// This.Selection.LanguageId( 1036 )
CASE 'DE'
This.Selection.LanguageId( 1031 )
CASE 'GR'
This.Selection.LanguageId( 1032 )
CASE 'IT'
This.Selection.LanguageId( 1040 )
CASE 'PT'
This.Selection.LanguageId( 2070 )
CASE 'ES'
This.Selection.LanguageId( 1034 )
CASE 'SU'
This.Selection.LanguageId( 1053 )
CASE ELSE
This.Selection.LanguageId( 1036 )

END CHOOSE

// invoke the spellchecker

CHOOSE CASE as_language
CASE 'FR', 'EN'
la_spellcheck_returncode = This.ActiveDocument.CheckGrammar()
CASE ELSE
la_spellcheck_returncode = This.ActiveDocument.CheckSpelling()
END CHOOSE

If IsNull( la_spellcheck_returncode ) Then

This.ActiveDocument.Content.Select

This.Selection.MoveLeft( 1, 1, 1 )

ls_spellchecked = This.Selection.Text

// copy the spellchecked selection back to the calling object

CHOOSE CASE apo_spellcheckobject.TypeOf( )

CASE datawindow!
ldw_sheet.SetText( ls_spellchecked )

CASE multilineedit!
lmle_object.Text = ls_spellchecked

CASE singlelineedit!
lsle_object.Text = ls_spellchecked

END CHOOSE


End If

// close the active document
This.ActiveWindow.Close( 0 )

//quit Word
This.Application.Quit

// disconnect the object
This.disconnectobject( )

---

Regards
Oliver Willandsen [European Commission - ]
Remove PAS_DE_PUB from Email address
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top