Apple Newton Utilities Guía de usuario Pagina 458

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 942
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 457
CHAPTER 11
Data Storage and Retrieval
11-26 Using Newton Data Storage Objects
This section presumes understanding of the material in “About Data Storage on
Newton Devices” beginning on page 11-1.
Most applications store data as frames that reside in soup entries. You can create a
frame by simply dening it and saving it in a variable, a constant, or a slot in
another frame. For example, the following code fragment denes a frame
containing the
aSlot and otherSlot slots. The frame itself is stored in the
myFrame variable. For all practical purposes you can treat variables that hold
NewtonScript objects as the objects themselves; hence, the following discussion
refers to the frame saved in the
myFrame variable as the myFrame frame.
myFrame := {aSlot: "some string data", otherSlot: 9258};
The myFrame frame contains two slots: the aSlot slot stores the "some
string data" string and the otherSlot slot stores the 9258 integer value.
Because every NewtonScript object encapsulates its own class data, you need not
declare types for NewtonScript data structures, including slots.
Frames are not persistent unless stored as soup entries. To add the
myFrame frame
to a soup, you must send a message to the appropriate soup object. You can obtain
a soup or union soup object by creating a new one or by retrieving a reference to
one that is already present.
To create a new union soup, use the
RegUnionSoup function to register its soup
denition with the system. The system uses this denition to create the union’s
member soups as needed to store soup entries.
The following code fragment saves the union soup object
RegUnionSoup returns
in the
myUSoup local variable. You might place code like this example in your
application (
form) part’s InstallScript function or your application base
view’s
ViewSetupFormScript method:
local aSlotIndexSpec := {structure: 'slot, path: 'aSlot,
type: 'string};
local otherSlotIndexSpec := {structure: 'slot, path: 'otherSlot,
type: 'int};
local mySoupDef := {name: "mySoup:mySig",
userName: "My Soup",
ownerApp: '|MyApp:MySig|,
ownerAppName : "My Application",
userDescr: "This is the My Application soup.",
indexes: [aSlotIndexSpec,otherSlotIndexSpec]
};
local myUsoup := RegUnionSoup('|MyApp:MySig|,mySoupDef);
Note the use of the mySig developer signature as a sufx to ensure the uniqueness
of the values of the
name and ownerApp slots. For more information regarding
developer signatures, see Chapter 2, “Getting Started.
Vista de pagina 457
1 2 ... 453 454 455 456 457 458 459 460 461 462 463 ... 941 942

Comentarios a estos manuales

Sin comentarios