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 theeditor:GetSoupData
method, which is shown in Listing 3-7.Listing 3-7 Reading a document from a soup
The TXWord program assumes that there should only be one word-processing entry in the soup. During program debugging, theeditor: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
editor:GetSoupData
method verifies this by checking for duplicate entries; if a duplicate entry is found,editor:GetSoupData
generates an exception.
Note that the
- 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.
![]()
editor:GetSoupData
method stores a reference to the soup entry in the sloteditor:theSoupEntry
. This slot is initialized tonil
when the TXWord program starts and is also used by theeditor:PutSoupData
method.
Main | Top of Section | What's New | Apple Computer, Inc. | Find It | Feedback | Help