Apple Newton Programmer’s Newton 2.0 (for Newton 2.0) User Manual

Page 706

Advertising
background image

C H A P T E R 1 9

Built-in Applications and System Data

19-32

Notes

Using the Notes Application

19

This section describes the methods that add new notes, and the Notes soup format.

To obtain a reference to the Notes application in order to send it messages, use the
following code:

GetRoot().paperroll

Note that future Newton devices may not include the Notes application. You should
therefore check for the existence of the Notes application before trying to access it.
Use the following code to test for this:

if GetRoot().paperroll then ...

Creating New Notes

19

The Notes method

MakeTextNote(

string

,

addIt

)

creates a note that consists of a

single string. The

addIt

parameter is a Boolean; pass

true

for

addIt

to add the note

to the Notes soup. The following code adds a note programmatically:

GetRoot().paperroll:MakeTextNote

("Isn’t this easy?",true);

If you want to add a more sophisticated note, follow these steps:

1. Create a note with

MakeTextNote

, but pass

nil

for the

addIt

parameter.

MakeTextNote

returns a note frame.

2. Modify the

data

slot of the frame returned by

MakeTextNote

. The

data

slot

must be an array of frames that have the format described in “Notes Soup
Format” (page 16-82) in Newton Programmer’s Reference.

3. Call the Notes method

NewNote

with the modified note frame.

Below is an example of this procedure:

// create a note frame

notes :=

GetRoot().paperroll;

theNote := notes:MakeTextNote ( "", nil);

// modify the data slot. Note that the data array now

// contains a frame for the empty string.

theNote.data :=

[{viewStationery :'para, // a text object

viewBounds : {top:3, left:3, right:97, bottom:97},

text : "I’m just a string."},

{viewStationery :'poly, //a polygon object

Advertising