Examples

Add Support for Date Find

We already created an index on the acquireDate slot; now all we have to do is notify newtApp of that slot. A QuickTime movie of this example is available.

1. Add the following slot to the newtApplication template:

dateFindSlot
'acquireDate

2. We also need a routine that provides a one-line summary for found entries. To accomplish this, we will add a FindSoupExcerpt slot to the newtApplication template with the following contents:

func(entry, resultFrame)
begin
   local t := "";

   // set the string, t, to a value based on slots
   // from entry
   if entry.acquireDate then
      t := t && ShortDateStr(entry.acquireDate,
         kFormatDefault);
   if entry.numberInStock then
      t := t && NumberStr(entry.numberInStock);
   t := t && entry.author && entry.title;
   return t;
end;

Note:Once we make our application stationery-based (see Chapter 11, Stationery), we won't need a FindSoupExcerpt method (the StringExtract of the dataDef will be used instead).


An online version of Programming for the Newton using Macintosh, 2nd ed. ©1996, 1994, Julie McKeehan and Neil Rhodes.

Last modified: 1 DEC 1996