C H A P T E R 1 1
Data Storage and Retrieval
11-20
About Data Storage on Newton Devices
Although the user might enter data dynamically, there might be a large initial set
of data your application needs to provide. Again, it's more efficient to supply
this as package data rather than as soup data.
You can supply multiple static data sets as separate packages to allow the user to
load some subset of that data. For example, a travel guide application might
keep data for individual countries in separate packages.
If your application makes use of a large initial data set to which the user can make
additions, you might consider a hybrid approach: keep the initial data set in your
base view's template and use a soup only for the user's additions.
A special-purpose object called a store part allows you to provide read-only soups
as package data; however, a soup residing on a store part cannot participate in a
union. For information about store parts, see Chapter 12, "Special-Purpose Objects
for Data Storage and Retrieval."
If you decide not to store your data in a soup, consider the following points:
Don't be too quick to discount frames as your data structure of choice--slot
lookup is very fast.
Storing data as a binary object can help you avoid some of the overhead associated
with array and frame data structures. In general, binary objects may let you store
your data more compactly, but make it more difficult to access: you'll need to
use the various
Extract
DataType functions to retrieve items. Note that the
ExtractCString
and
ExtractPString
functions create a string object in
the NewtonScript heap for each string extracted from a binary object.
Consider storing symbols for repeated strings rather than storing the strings
themselves. When you define a symbol for an object (such as a string or frame),
only one instance of the object is stored in the application package, and all the
symbols reference that instance. Remember that symbols are limited to 7-bit
ASCII values. Symbols (slot names) can include nonalphanumeric ASCII
characters if the name is enclosed by vertical bars; for example, the space in the
symbol
'|Chicken Little|
would normally be illegal syntax, but the
vertical bars suppress the usual evaluation of all characters they enclose.
Compatibility Information
11
This section provides version 2.0 compatibility information for applications that
use earlier versions of the data storage and retrieval interface.
Obsolete Store Functions and Methods
11
The following store methods and functions are obsolete:
store
:CreateSoup (
soupName
,
indexArray
) // use CreateSoupFromSoupDef
RemovePackage(
pkgFrmOrID
) // use SafeRemovePackage instead
store
:RestorePackage(
packageObject
) // use SuckPackageFromBinary instead