Apple Newton Utilities Guia do Utilizador Página 459

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 942
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 458
CHAPTER 11
Data Storage and Retrieval
Using Newton Data Storage Objects 11-27
When creating soups from within your application (form) part’s InstallScript
function, remember that this function calls the
EnsureInternal function on
all values it uses. Thus, instead of passing references such as
partFrame.theForm.myMainSoupDef to the RegUnionSoup function, paste
a local copy of your soup denition into your application part’s
InstallScript
function for its use.
The
RegUnionSoup function uses the value of your soup denition’s name slot to
determine whether a particular soup denition has already been registered. You
need not be concerned with registering a soup denition twice as long as you don’t
register different soup denitions that have the same name. An application that
registers a soup denition when it opens can always use the union soup object
returned by the
RegUnionSoup function—if the union soup named by the soup
denition exists, this function returns it; otherwise, this function uses the specied
soup denition to create and return a new union soup.
The next code fragment uses the
AddToDefaultStoreXmit function to add the
myFrame frame to the myUSoup union soup. This function creates a new member
soup to hold the entry if necessary. The soup is created on the store indicated by the
user preference specifying where new items are kept.
myUSoup:AddToDefaultStoreXmit(myFrame, '|MyApp:MySig|);
At this point, we have created a soup on the store specied by the user and added
an entry to that soup without ever manipulating the store directly.
Because you’ll often need to notify other applications—or even your own
application—when you make changes to soups, all the methods that modify
soups or soup entries are capable of broadcasting an appropriate soup change
notication message automatically. In the preceding example, the
AddToDefaultStoreXmit method notifies applications registered for changes
to the
myUSoup union soup that the '|MyApp:MySig| application added an
entry to this union soup. For more information, see “Callback Functions for Soup
Change Notication” (page 9-14) in Newton Programmers Reference.
Most of the time, your application needs to work with existing soups rather than
create new ones. You can use the
GetUnionSoupAlways function to retrieve an
existing soup by name.
Once you have a valid soup object, you can send the
Query message to it to
retrieve soup entries. The
Query method accepts a query specication frame as its
argument. This frame denes the criteria soup entries must meet in order to be
retrieved by this query. Although you can pass
nil as the query spec in order to
retrieve all the entries in a soup, usually you’ll want to retrieve some useful subset
of all entries. For example, the following code fragment retrieves from
myUsoup
all entries having an
aSlot slot. For an overview of the use of query specications,
see “Using Queries” beginning on page 11-38.
Vista de página 458
1 2 ... 454 455 456 457 458 459 460 461 462 463 464 ... 941 942

Comentários a estes Manuais

Sem comentários