Examples
author
title
numberInStock
acquireDate
allSoups
slot of the newtApplication template to:
It is very important to create a{
mySoup: { _proto: newtSoup, soupName: "Bookstore:Calliope", soupIndices: [
{
structure: 'slot,
path: 'author,
type: 'string,
},
{
structure: 'slot,
path: 'title,
type: 'string,
},
{
structure: 'slot,
path: 'acquireDate,
type: 'int,
},
{
structure: 'slot,
path: 'numberInStock,
type: 'int,
},
], soupQuery: {indexPath: 'author},
CreateBlankEntry: func()
begin return { author: "",
title:"",
acquireDate: Time(), // today! numberInStock: 1, price: 15.95, // most common price };end, }, }
CreateBlankEntry
along with our soupQuery
. If CreateBlankEntry
were not present, then when the application opens, a blank entry with no slots would be created. When this entry was added to the soup, it wouldn't be added to the author
index, as there would be no author
slot. The cursor that used the author
index would then skip this blank entry. Now, the default layout would get in deep trouble-- it would be trying to edit an entry that wasn't part of the cursor. This trouble is completely avoided if our CreateBlankEntry
ensures that all slots necessary for our indexes are filled out in advance.When we test our application, we find that as new entries are created (by initially opening the application, or by switching to an empty folder), they have reasonable default values. In addition, entries are sorted by author.
soupIndices
array after you've created the soup, you'll get this error: Key does not have the type specified in the index
evt.ex.fr.store
-48019
Once a soup has been created it maintains its original index(es). Even if you update the soupIndices
slot in allSoups
and rerun your application, it won't add new indexes. The soupIndices
is used only when a soup is created.
An online version of Programming for the Newton using Macintosh, 2nd ed. ©1996, 1994, Julie McKeehan and Neil Rhodes.
Last modified: 1 DEC 1996