Title Banner

Previous Book Contents Book Index Next

Newton Developer Technical Information: Newton Programmer's Guide: 2.1 OS Addendum /
Chapter 3 - Word Processing Views / Using Word Processing Views


Reading a Word-Processing Document From a Soup

To read a word-processing document that you have previously created in your application, you can access the document in a soup and then call the *protoTXView:*Internalize method, which replaces the view's contents with the document data. The TXWord program implements this in the editor:GetSoupData method, which is shown in Listing 3-7.

Listing 3-7 Reading a document from a soup

editor:GetSoupData:

func() begin local soup := GetUnionSoup(kSoupName); if soup then begin local query := soup:Query(nil); // set our slot with the entry, if there theSoupEntry := query:entry(); if theSoupEntry then self:Internalize(theSoupEntry.EditorData); end; end

The TXWord program assumes that there should only be one word-processing entry in the soup. During program debugging, the editor:GetSoupData method verifies this by checking for duplicate entries; if a duplicate entry is found, editor:GetSoupData generates an exception.

Note
The TXWord model of reading a document from a soup is not necessarily the correct approach for your application. It works for TXWord's relatively simple style of managing its documents.
Note that the editor:GetSoupData method stores a reference to the soup entry in the slot editor:theSoupEntry. This slot is initialized to nil when the TXWord program starts and is also used by the editor:PutSoupData method.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
26 APR 1997



Navigation graphic, see text links

Main | Top of Section | What's New | Apple Computer, Inc. | Find It | Feedback | Help