
Adding a New Kind of Data to the Notepad
Enhance the dataDef
Now that we are up and running, let's make a couple of enhancements (a QuickTime movie of this example is available):
- Let's make sure that information displays in the overview.
- If the user taps on the icon to bring up an information slip, we should provide a textual description.
- We should supply reasonable default values when creating a new Temperature form.

FIGURE 11.10 : Creating a new Temperature form and resizing in the Notes application.
In order to do all these things, we'll add some optional slots to the dataDef.
1. First, let's modify the description
slot to say:
"Temperature (Neil Rhodes)"
And a version
slot:
1
2. Now, add a StringExtract
slot that will provide the text for the overview:
func(e, nLines)
begin
local t := "";
if e.(kDataDefSym).temperature then
t := t & "Temp:" &&
NumberStr(e.(kDataDefSym).temperature);
if e.(kDataDefSym).windSpeed then
t := t & " Wind:" &&
NumberStr(e.(kDataDefSym).windSpeed);
return t;
end;
3. Finally, we'll add a FillNewEntry
method to fill in default values:
func(e)
begin
e.(kDataDefSym).temperature := 40;
e.(kDataDefSym).windSpeed := 11;
return e;
end;
Caution:
When you remove a package that contains a viewDef, make sure that viewDef isn't in use. This would happen if you are displaying a piece of stationery in the Notepad and then download a new version. Your only recourse after doing so is to reset the Newton. (You'll find this is something you often remember just after you start to download your stationery--by then it is too late.)
One solution to this is to automatically close the application you are adding stationery to in your RemoveScript
:
GetRoot().paperroll:Close()
Now build and download. New entries should have a default temperature and wind speed. The overview should display the temperature and wind speed (see FIGURE 11.11). Tapping on the Temperature icon should produce the information slip containing our string (see FIGURE 11.12).

FIGURE 11.11 : Overview displaying result of dataDef's StringExtract
.

FIGURE 11.12 : Information slip after tapping on Temperature icon.
An online version of Programming for the Newton using Macintosh, 2nd ed. ©1996, 1994, Julie McKeehan and Neil Rhodes.
Last modified: 1 DEC 1996