Apple Newton Utilities User's Guide Page 493

  • Download
  • Add to my manuals
  • Print
  • Page
    / 942
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 492
CHAPTER 11
Data Storage and Retrieval
Using Newton Data Storage Objects 11-61
Copying Entries 11
The EntryCopyXmit global function and the CopyEntriesXmit soup method
enable you to copy entries from one soup to another and transmit appropriate
change notications.
The following code fragment uses the
CopyEntriesXmit soup method to copy
all the entries from a specied source soup into a specied destination soup. Note
that this method is dened only for soups, not for union soups. The following code
fragment uses the
GetMember union soup method to retrieve the plain soup
constituent of a union soup from a specied store. The
GetMember method never
returns
nil; instead, it creates an empty member soup on the specied store if one
does not already exist:
// myUsoup member on internal store is the source soup
local myUSoup := GetUnionSoupAlways("myUSoup:mySig");
local sourceSoup := myUSoup:GetMember(GetStores()[0])
// myUsoup member on another store is the destination soup
local destSoup := myUSoup:GetMember(GetStores()[1]);
// copy all entries from source soup to dest soup
local cursor := sourceSoup:Query(nil);
if (cursor:CountEntries() <> 0) then
sourceSoup:CopyEntriesXmit(destSoup, '|MyApp:MySig|);
You can use the EntryCopyXmit function to copy an entry from a specied
source soup to a specied destination soup and transmit a soup change notication
message. Note that this function is dened only for soups, not for union soups. The
following code fragment uses the
GetSoup store method to retrieve a specied
soup from its store. Because the
GetSoup method returns nil when the soup to
be retrieved is not available, you must at least ensure that this result is non-
nil
before using it. The following code fragment actually goes one step further and
uses the
IsValid soup method to test the validity of the destSoup soup in
additional ways:
local myUSoup := GetUnionSoupAlways("myUSoup:mySig");
// get all entries having 'hot in 'temperature slot
local cursor := myUSoup:Query({indexPath: 'temperature,
beginKey: 'hot
endKey: 'hot});
local destSoup := GetStores()[0]:GetSoup("mySoup:mySig");
// make sure we actually got a valid soup
if destSoup:IsValid() then
begin
// xmit a single notification after all changes are made
while e := cursor:Entry() do EntryCopyXmit(e,destSoup,nil);
XmitSoupChange(destSoup, '|MyApp:MySig|, 'whatThe, nil);
end;
Page view 492
1 2 ... 488 489 490 491 492 493 494 495 496 497 498 ... 941 942

Comments to this Manuals

No comments