Laptop Battery
-- IBM is a global leader in the creation, development and manufacture of cutting edge computer systems.
- Microsoft
Thinkpad Implement Server-Side Spell Checking with Microsoft Word by Jason
According to the indictment, Jones would steal various IBM and Penguin computer servers from Verisign's warehouse in Virginia and sell them to Johnson. Johnson would then sell the servers to several individuals, who would sometimes place them for sale on eBay. As a result of this scheme, the indictment alleges that Jones and Johnson caused Verisign to lose more than $120, 000 worth of computer equipment. In the indictment, Jones and Johnson are charged in three counts with causing the interstate transportation of stolen property, namely IBM 330 and 335 servers, in violation of 18 U.S.C.
Microsoft Fisher
check your spelling.
- Use only one or two words.
- For specific results, search by category to the left.
Laptop Computers If you've ever built a Web application that relies heavily on user input--a
6. Spell checking with your computer isn't enough. Many words sound similar but have different meanings, and spell check won't catch it. This is especially true if English is your 2nd language. An accent or slang can be charming when spoken, but can look incompetent when written.
Laptop Computer Web-based message board application, for example--you've probably wondered how
4 Edits are made to Microsoft Word documents via the Documents To Go® application. Some editing functionality is not supported, such as multiple font sizes and spell check. During synchronization with the desktop, edits are copied to the desktop version of the document. 5 Changes are made on the device via the Documents To Go application. Some editing functionality is not supported, such as multiple font sizes and spell check.
Desktop Computer to add spell-check capability to it. Most higher-tier Web applications (such as
Notebooks MSN's Hotmail) provide this feature in one way or another, and it can go a long
Lenovo way to separate you from the amateurs if you can provide this functionality on
Hard Drive your site as well. But how? The most direct approach, of course, might be to
Travelstar write your own server-side, spell-checking component in Visual Basic or C++, and
Gateway while this would certainly accomplish the goal (months later!), it's
Laptop Parts unnecessarily reinventing the wheel. If you're running Microsoft Word on your
Software Web server, you can easily automate the use of its proofreading capabilities for
Hard Drives your own Web pages, and it's a lot less work than you might think. In this
Electronics article, we'll show you how to use these capablilities to implement
Canon spell-checking like that shown in Figure A.
Desktop Pc Figure A: We'll show you how to implement Word's spell-checking in
Desktop Computers server-side ASP.
Think Pad OverviewAs an example, we're going to build a simple Web form that
Repair allows a user to submit some text for spell-checking. The results will then be
Data Recovery displayed on another page, along with suggestions for correcting each spelling
Cisco error. In addition, when the user clicks on any of these suggestions, the
Keyboard misspelled word will be replaced with the suggestion and the results
Monitor redisplayed. In this way, a submission with multiple errors can be incrementally
Desktop corrected until no errors remain. Our particular sample application is rather
Infosys useless, all things considered, but its simplicity will allow us to illustrate
Refurbished Laptops the technique without the additional distractions introduced by a more
Wipro complicated real-world example. Once you've learned how to implement server-side
Lap Top spell-checking with ASP and Microsoft Word, you can take this approach to a more
Refurbished useful and feature-rich Web application like a message board or email
Memory application.
Intel To begin our approach, we'll first launch Word, invisibly, on the Web server.
As400 Then, we'll create an empty document, into which we'll stuff the content
Averatec submitted through a Web form by the user. Then, we'll invoke Word's native
Hardware spell-check capabilities to retrieve a collection of spelling errors and their
Dual Xeon suggested corrections. Our Web page will display these results in a table and
Storage will allow the user to replace misspelled words with the provided suggestions.
Seagate Once this process is complete, we'll close down the instance of Word. And all of
Computer Sales this will be completely transparent to the end-user. That said, let's take a
Computer Hardware look at the process up close.
Printers Getting something to spell-checkOur first step is to create the simple
Technology HTML form that we'll present to the user for his submission. The form should
Mainframe look something like the illustration in Figure B. Go ahead and create a new HTML
Samsung document, enter the code from Listing A, and save the file as
Computer Repair SpellCheck.html.
Used Computers Figure B: We'll submit this form to our server-side
Network spell-checker.
Digital Cameras This form is simple enough that its construction and function are
Desktops self-evident, so we won't say much more about it. The only thing we do want to
Cognos point out is that we're soliciting the user's input in a <textarea> called
Hosting txtSubmit, which we post to an ASP page called SpellCheck.asp. It's this ASP
Netfinity page that does the real work, and we'll spend the remainder of this article
Internet discussing how it gets the job done.
Cheap Computer Listing A: The HTML form <html>
Digital Camera <head>
Printer <title>
Xseries Server-Side Spell Check
Maxtor </title>
Data Storage </head>
Hitachi <body>
Rational <font size=5>
Websphere <b>Server-Side Spell Checking<br>
Battery with ASP and Word</b><br><br>
It Support </font>
Western Digital <table>
Music <tr>
Networks <td>
Toner <form method=post action=SpellCheck.asp>
Cheap Laptops <b>Spell Check the Following:</b><br>
Wholesale <textarea name=txtSubmit rows=10
Brother cols=58></textarea><br>
Netvista </td>
Camera </tr>
Networking <tr>
Sharp <td align=right>
Cheap <input type=submit value="Spell Check">
Windows </form>
Monitors </td>
Linux </tr>
Computer Support </table>
Used Laptops </body>
Cameras </html>
Scanners
Panasonic Getting the job doneFigure B depicts the results of submitting the form
Workstation shown in Figure A. As you can see, this submission contains seven spelling
Iseries mistakes, and each has one or more suggestions for correcting the error. The
Backup user can click any one of these suggestions, whereupon the page is refreshed to
Information Technology reflect the change. Listing B contains the code required to make this happen.
Routers Next we'll turn our attention to exactly what the SpellCheck.asp is doing.
180gxp Listing B: Let the Spell-checking begin! <%
Notebook Battery option explicit
Security 'Dimension object variables
Lotus dim objWord 'as Word.Application
Virus dim objDocument 'as Word.Document
Thinkpad T42 dim objErrors 'as Word.ProofreadingErrors
Thinkpad 600 dim objError 'as Word.Range
Thinkpad 600e dim wdSuggestions 'as Word.SpellingSuggestions
Thinkpad 570 dim wdSuggestion 'as Word.SpellingSuggestion
Thinkpad 600x dim strSubmission, strModified, intCounter
Thinkpad 390x const wdDoNotSaveChanges = 0
Thinkpad A31 'Capture submitted text from Form or QueryString
Thinkpad X20 strSubmission = request("txtSubmit")
Bios Update 'Echo submission back to the user
Laptops with response
Toshiba .write "<font size=5><b>"
Laptop Battery .write "Spelling Results</b></font>"
Thinkpad .write "<br><br>"
Microsoft .write "<b>You submitted the following:</b><br>"
Laptop Computers .write """ & strSubmission & ""<br><br>"
Laptop Computer end with
Desktop Computer 'Launch Word and create a new document
Notebooks set objWord = server.createObject("Word.Application")
Lenovo set objDocument = objWord.documents.add
Hard Drive 'Insert the user's submitted text into the document
Travelstar objWord.selection.typeText cstr(strSubmission)
Gateway 'Retrieve and display spelling errors
Laptop Parts set objErrors = objDocument.spellingErrors
Software if objErrors.count then 'there are errors
Hard Drives with response
Electronics .write "<table><tr><td><b>Spelling Error "
Canon .write "</b></td><td><b>Suggestion</b></td></tr>"
Desktop Pc end with
Desktop Computers for each objError in objErrors
Think Pad 'Display the misspelled word
Repair response.write "<tr valign=top><td>"
Data Recovery response.write objError.Text & "</td><td>"
Cisco 'Get spelling suggestions for the word
Keyboard set wdSuggestions = _
Monitor objWord.getSpellingSuggestions(objError.text)
Desktop if wdSuggestions.count < 1 then
Infosys response.write "No suggestions"
Refurbished Laptops else
Wipro intCounter = 0
Lap Top for each wdSuggestion in wdSuggestions
Refurbished intCounter = intCounter + 1
Memory strModified = replace(strSubmission, _
Intel objError.text, wdSuggestion.name, 1, 1)
As400 with response
Averatec 'Construct anchor tag
Hardware .write "<a href=SpellCheck.asp?"
Dual Xeon .write "txtSubmit="
Storage .write server.URLEncode(strModified)
Seagate .write ">" & wdSuggestion.name & "</a>"
Computer Sales end with
Computer Hardware 'Display a pipe-delimiter except at the end
Printers if intCounter < wdSuggestions.count then
Technology response.write " | "
Mainframe end if
Samsung next
Computer Repair end if
Used Computers response.write "</td></tr>"
Network next
Digital Cameras with response
Desktops 'Show the user number of errors found
Cognos .write "</table>"
Hosting .write "<br><b>" & objErrors.count
Netfinity .write " spelling error(s) found:</b>"
Internet .write " Click suggestions to correct."
Cheap Computer end with
Digital Camera else 'no errors were found
Printer response.write "<b>No spelling errors found.</b>"
Xseries end if
Maxtor 'Close running instance of Word and destroy objects
Data Storage objWord.Quit wdDoNotSaveChanges
Hitachi set objDocument = Nothing
Rational set objWord = Nothing
Websphere set objErrors = Nothing
Battery set wdSuggestions = Nothing
It Support %>
Western Digital
Music We begin, as always, by declaring the variables we'll be using to carry out
Networks the spell-checking process. In addition to a few variables for holding onto
Toner ordinary data, we'll need several object variables to represent native Word
Cheap Laptops components. In VBScript, where all variables are actually variants, these
Wholesale variables are not strictly typed; however, you should be aware of the actual
Brother object types (commented in the code above). You can automate Word's
Netvista spell-checking facilities in a conventional Visual Basic application just as
Camera easily as you can in ASP, but to do so, you'll need to know the object types in
Networking question. Figure C shows the basic relationship between some of the Word objects
Sharp and collections relevant to this example.
Cheap Figure C: These are the relevant objects in Word's object
Windows model.
Monitors After declaring your variables, you then proceed to capture the user's text
Linux submission into the variable strSubmission. Technically, the precise way to
Computer Support reference a submitted form field is
Used Laptops request.form("txtSubmit") however, the reference to the
Cameras form object can be omitted. When it's left out, ASP searches each available
Scanners collection in the request object for a member with the provided name in the
Panasonic following order: QueryString, Form, Cookies, ClientCertificate, ServerVariables.
Workstation We'll be making use of this feature later in our code, as you'll see. For now,
Iseries on the initial pass through SpellCheck.asp, request("txtSubmit") retrieves the
Backup submission the user typed into the form (SpellCheck.html). The next thing you do
Information Technology is echo back to the user the text that he submitted. This serves a couple of
Routers purposes: it allows the user to look back at his submission to locate each error
180gxp displayed below, and it permits him to see the incrementally corrected form of
Notebook Battery his submission as he selects spelling suggestions.
Security How do you spell relief?Now the real fun begins. You use the
Lotus CreateObject method of the Server object to launch an instance of Microsoft
Virus Word. In a conventional desktop application, you would need to set the Visible
Thinkpad T42 property of this application instance to False to prevent its being displayed on
Thinkpad 600 the user's desktop; however, this isn't necessary when the application instance
Thinkpad 600e is created on a Web server. Once you have an instance of Word running in the
Thinkpad 570 background of our Web server, create a new document by calling the Add method of
Thinkpad 600x Word's Documents collection. Initially, this document is empty, so you can now
Thinkpad 390x proceed to fill it with the submission made by your user, which is stored in
Thinkpad A31 strSubmission. When the document is first created, no selection is set (in fact,
Thinkpad X20 there is nothing to select, since the document contains no content), and
Bios Update therefore, when you pass the user's submitted text to the TypeText method of the
Laptops Selection object, this text is merely dropped in at the current cursor position,
Toshiba the beginning of the document.
Laptop Battery Now, you need to see what spelling errors (if any) the submission contains.
Thinkpad To make this determination, you don't actually have to do any work at all, since
Microsoft our Word document automatically populates its own SpellingErrors collection on
Laptop Computers the fly. All you have to do, as you can see in the code, is get a reference to
Laptop Computer this collection and then loop through it. So, for each error that we find in the
Desktop Computer collection, we'll display the misspelled word and then get Word's suggestions
Notebooks for how to correct the mistake.
Lenovo The Word Application object contains a method called GetSpellingSuggestions
Hard Drive that returns a collection of spelling suggestions for any text passed to it. So
Travelstar all you do is call this method, sending it each misspelled word (from the
Gateway Document's SpellingErrors collection); then, iterate through the resulting
Laptop Parts collection of suggestions that Word returns.
Software For each suggestion provided to you, you' re going to display it and create
Hard Drives an anchor tag to enclose it. This anchor tag encapsulates a quick and clever
Electronics method for replacing a misspelled word with one of the suggestions. The approach
Canon is to create a string variable, strModified, in which we use VBScript's replace
Desktop Pc function to exchange the misspelled word, held in objError.text, with the
Desktop Computers spelling suggestion provided from Microsoft Word's built-in dictionaries, held
Think Pad in wdSuggestion.name. You'll then include this value with the QueryString in the
Repair HREF attribute of our anchor tag.
Data Recovery Remember our discussion about the sequence in which ASP scans the available
Cisco collections in the Request object for our txtSubmit member? This is where we
Keyboard take full advantage of the flexibility afforded to us by this generic
Monitor referencing capability. Our anchor will point to this self-same ASP page as its
Desktop target, passing strModified as the value for txtSubmit.
Infosys Originally, this value came from a form field, but on subsequent entries to
Refurbished Laptops the page, it will come from the QueryString. This allows you, one word at a
Wipro time, to correct misspellings in the submitted text and simplifies your coding
Lap Top considerably. One caveat: you need to remember to URLEncode the text before you
Refurbished submit it back to the page through the QueryString, because the submission may
Memory contain carriage returns, line feeds, or HTML-reserved characters such as the
Intel ampersand (&) or question mark (?), and you need these to be properly
As400 preserved rather than interpreted.
Averatec Once you've finished traversing the collection of misspelled words (if there
Hardware were any), you'll display for the user the total number of mistakes found. And
Dual Xeon of course, if there are no errors at all, you'll indicate this to the user.
Storage At this point, the process is essentially complete. All that remains is to
Seagate close down your running instance of Microsoft Word. You do this with the Quit
Computer Sales method of the Application object, passing the constant wdDoNotSaveChanges to
Computer Hardware indicate that we want to discard the contents of our working document. We then
Printers clean up our memory utilization by setting all of our object variables to
Technology Nothing, and we're all finished.
Mainframe A few closing words about WordYou've seen here that it isn't terribly
Samsung difficult to control Microsoft Word in the background on your Web server, and
Computer Repair that in this way, you can leverage any of its many built-in features for use by
Used Computers your own Active Server Pages. In this case, we implemented spell-checking
Network functionality; however, you could just as easily add grammar checking. In
Digital Cameras addition, a possible enhancement to this example would be to explore the use of
Desktops custom dictionaries. Word can reference up to 10 custom dictionaries
Cognos simultaneously, allowing users to add their own words not found in Microsoft
Hosting Word's built-in dictionary. Support for multiple languages is also another
Netfinity direction in which you could take this example. A word of warning: this approach
Internet is fairly memory-intensive, because of its reliance upon complex objects and
Cheap Computer involved processes running in the background on your Web server. If you're
Digital Camera looking to implement this technique on a site with heavy traffic, you'll need a
Printer pretty beefy server. In addition, you'll probably want to take certain
Xseries optimization measures, such as launching only one instance of Word in your
Maxtor Global.asa, making it available to all running sessions, and leaving it open
Data Storage instead of closing it at the end of SpellCheck.asp. In any event, for many
Hitachi applications, this remote automation of Microsoft Word will allow you to add
Rational functionality to your Web site that you may have only dreamed about before.
Websphere Copyright 2000 Content LLC.
Battery All rights reserved. Reproduction in whole or in part in any form or medium
It Support without express written permission of Element K Content LLC is prohibited.
Western Digital Element K is a service mark of Element K LLC.
Music
[ Comment, Edit or Article Submission ]