Programming for the Newton using Macintosh, 2nd ed.


Foreword by Walter Smith
Acknowledgments
Preface
Preface to the Second Edition
The Structure of the Book
This is a 2.0-specific Book
What You Need to Know to Program the Newton
Macintosh Knowledge
Newton Experience
Programming Experience
Introduction
Overview
A Newton Glossary
The Life Cycle of an Application
Before Installation
The Sample Application
Installing an Application
Running an Application
Closing an Application
Removing an Application
Persistent Data on the Newton
Sharing Data
Newton Interface Design
Do Not Design for a Personal Computer
The Personal Computer World
The Newton World
General Design Guidelines
Keep It Small
Keep It Simple
Keep It Personal
Make It Fast
Newton Applications Must Be Easy to Use
Emphasize Tapping over Writing
Anticipate the User's Action
Give the User Update Information
Status Information
View and Button Effects
Do Not Underestimate the Value of Whizbang Features
When to Leave Partial Views
Use the Correct Proto or viewClass
Summary
Using NTK
System Requirements
Install Demo NTK
Differences between Demo NTK and NTK
Get Started with NTK
Specify to NTK How You'll Connect the Newton
Serial Connection on a PowerBook with Only One Serial Port
Connect the Newton to the Mac
Download the Toolkit App
Connect the Inspector
Verify the Connection
Build Your First Application
Create a Project
Change Project Settings
Create a Layout with Templates
Put Templates in a Parent-Child Hierarchy
Move and Change Template Size Graphically
Name Templates
Add a Layout to the Project
Build the Application
Download the Application
Make Changes to the Application
An Introduction to the Browser
Add a Slot
Disconnect the Inspector
Common Problems and Questions about NTK
Hints for Using NTK Effectively
Keep the Inspector Connected
Extras as a Backdrop Application
Download Package after Building
Use AppleTalk for Connection
Show Slot Values
Exercises
Fundamentals of NewtonScript
A Brief Overview of NewtonScript
Frames
Creating Frames
Frames within Frames
Accessing Slots
Accessing a Nonexistent Slot
Creating Slots
Multilevel Slot Creation
Removing Slots
Slot Existence
Arrays
Creating Arrays
Adding Elements
AddArraySlot
SetLength
Removing Elements
ArrayRemoveCount
SetLength
Using Arrays as Sets
SetAdd
SetRemove
SetUnion
SetDifference
SetContains
SetOverlaps
Symbols and Path Expressions
Symbols
Path Expressions
Using Path Expressions for Constants
Iterating with foreach
foreach with Arrays
foreach with Frames
foreach with Slot Names
Types
What Types Can Be Modified
Clone/DeepClone
Methods
Local Variables
Message Sending
self
Variable Lookup Rules
Effects of Variable Lookup Rules
Additional NewtonScript Features
Other Standard Types
Strings
Examples
Accessing String Elements
Unicode
Operators
if/then/else Statements
Loops
Break
while
repeat
loop
for
for/foreach collect
The Benefits of NewtonScript
Portability
Garbage Collection
NewtonScript Examples
Min Function
A Counter Object
An Application That Prints "Hello world" to the Inspector
Exercises
Summary
Inheritance in NewtonScript
Overview of NewtonScript Inheritance
The Mechanics of Inheritance
Comparing Prototype Inheritance and Class-Based Inheritance
Proto Inheritance
Proto Inheritance and Inheritance Lookup
Multiple Protoing
Slot Assignment
Objects Should Be Independent
Protos May Be in ROM
Assignment to Inherited Slots
The inherited Keyword
The :? Operator
The deeply Version of foreach
Parent Inheritance
Combining Proto and Parent Inheritance
Accessing Slots
Testing for the Existence of Slots
Inherited
Using self in a Method
Don't Use _parent
Use Parent Inheritance for Inheriting Data
NewtonScript, Newton Toolkit, and the Newton
Newton Runtime Views
NTK Templates
Seeing the _parent Slot
Exercises
Summary
View Attributes
What's in a View
Common View Slots
viewBounds
viewFlags
Flags That Affect the Behavior of the View
Flags That Affect Input
Flags That Affect Text Input
viewFormat
The View Frame
The View Fill
The View Lines
Some viewFormat Examples
viewClass
Other View Settings
viewEffect
viewFont
Miscellaneous Settings
Justification
Why Use Justification?
Newton Is a Family of Products
Design Changes Are Easier
Using Justification
How Justification Is Done
Ways to Justify a View
Parent Justification
Left and Right Justification
Top and Bottom Justification
Center Justification
Full Justification
Uses of Parent Justification by Protos
Sibling Justification
Interactions between Parent and Sibling Justification
Example
Justification of the Application Base View
Ratio Justification
Child in Top-Left Sixteenth of Parent
Child in Bottom-Right Sixteenth of Parent
Three Children Partitioning a Parent
Text and Graphics Justification
Examples
Copy to Clipboard from Static Text
Exercises
Large Static Text
An Input Line Accepting Phone Numbers
An Application with a View Effect
A Full-Screen application
Summary
View System and Messages
How Views Are Created
viewSetupFormScript()
Setting Values in viewSetupFormScript
Changing Slots in viewBounds
Setting the Application Size at Run-time
viewSetupChildrenScript()
stepChildren and viewChildren
Creating Children Dynamically
viewSetupDoneScript()
viewShowScript()
How Views Are Destroyed
viewQuitScript()
viewHideScript()
Other Messages the View System Sends
viewOverviewScript()
viewScrollUpScript()
viewScrollDownScript()
viewClickScript(unit)
ReOrientToScreen()
viewIdleScript()
View Messages You Send
Close()
Open()
Hide()
Show()
Hilite(turnOn)
Dirty()
LocalBox()
GlobalBox()
ChildViewFrames()
Changing View System Attributes
Declaring Views
Sibling Messages and Declaring
Invisible Views
Don't Declare All Views
Application Base View
InstallScript, RemoveScript, and DeletionScript
Sample InstallScript and RemoveScript
Warnings for RemoveScripts
Keep RemoveScript Small
Examples
Set Minimum and Maximum Sizes for an Application
Maximum Size
Minimum Size
Reorganize Views in Landscape Mode
Opening the Application Automatically
Exercises
Display Current Time
Modify viewFormat Programmatically
Summary
Protos
Introduction to Protos
Kinds of Protos
Proto Nuts and Bolts
Protos and Template Size
Protos Provide Template Reuse
Protos Reduce Application Size
Protos Increase Maintainability
Protos Can Be Shared between Projects
The System Protos
Some Useful System Protos
Configuration of Some System Protos
protoPictureButton
protoCloseBox
protoApp
protoLabelInputLine
Creating and Using User Protos
How NTK Handles System Protos
How NTK Handles User Protos
Referring to User Protos from Your Code
Examples
Beeping Button Proto
Exercises
Current Time Proto
Build Time Proto
Summary
Debugging Your Application
The Inspector
Evaluating NewtonScript Code
Example
Restrictions
Execution Environment
Functions
Printing
Controlling the Depth of Printing
Controlling the Number of Slots Printed
Tracing
Turning Tracing On and Off
Example
Gotchas with Tracing
Turning Tracing Off
Tracing Doesn't Take Effect Immediately
Debugging Functions
Debug
Searching the Text Slot
Protos Containing Text Slots
Searching the Debug Slot
The Debug Slot in ROM Protos
GetView
DV
NS Debug Tools
Exceptions
Breaking on an Exception
The Thorns of Break Loops
Breaking Using BreakLoop()
Exiting a Break Loop
Showing a Stack Trace
Example
Named Variables and Parameters
Getting the Value of self
Getting Functions
Disassembly
Breakpoints
Stepping
The Interpreter Stack
The Debugging Process
Use breakOnThrows
Read Error Messages
Determine Where the Error Occurred
Print Is Your Friend
Remove Debug Code for Non-debug Builds
Examples
Beeping Button Brouhaha
First Problem
Second Problem (a Hard One)
Third Problem
Fourth Problem
Exercises
Fails When Installing
Fails When Opening
Summary
Newton Data Storage
Introduction
Persistent Objects
Soups
Soup Indexes
Searching through Every Entry
Starting at the Right Place
Ending at the Right Place as Well
Tag Indexes
Multislot Indexes
When to Use an Index
Sharing Data between Applications
Reading Data from Another Soup
Adding Slots to Other Soup Entries
One Copy of Data
Change Notification
Stores
Union Soups
When Soups Get Created
Queries/Cursors
Soup Entries Are Self-Contained
Soup Entries Have a Unique ID
Soup Entry Compression
Description of Methods and Functions
Soup Change Notification
Index Specification Frames
Store Functions
Soup Creation
Getting Soup Names
Finding Soups
Miscellaneous Store Functions
Soup Functions
Soup Defs
RegUnionSoup
UnRegUnionSoup
Returning a Union Soup
Adding an Entry to the Union Soup
Miscellaneous Soup Methods
Cursor Functions
Creating a Query Specification Frame
Tag Specification Frame
Moving Cursors
Entry Functions
Handling Soups in Your Application
What's in a Soup Name
Calling RegUnionSoup
Calling UnRegUnionSoup
When to Remove Soups
Handling Changes to Your Soup
Examples
Printing All the Names in the Names Soup
In Unsorted Order
In Sorted Order
Printing All Names Beginning with "K"
Slow Way
Faster Way
Fastest Way
Changing an Entry in an Existing Soup
Adding Slots to Entries in an Existing Soup
Finding All Names Matching a String
Text Search
Words Search
Removing a Store While a Cursor Is Iterating
Removing an Entry While a Cursor Is Iterating
Forgetting to Call EntryChangeXmit
Exercises
Application That Displays All Soup Names
Index Speed Tests
Summary
NewtApp
What Is NewtApp?
When to Use NewtApp
When Not to Use NewtApp
Architecture of NewtApp
Application Layer
Layout Layer
Entry Layer
Slot Layer
How They Fit Together
Application Layer
NewtApplication
Required Slots
Optional Slots
Useful Slots
Other Application Layer Templates
newtClockFolderTab/newtFolderTab
newtStatusBar
newtSoup
Required Slots
Optional Slots
Useful Slots
Layout Layer
newtLayout/newtOverLayout
Required
Optional
newtOverLayout
Optional
Entry Layer
newtEntryView
Useful
Slot Layer
List of All Protos
All Slot Layer Protos
Required Slot
Label Slot Protos
Required Slot
Optional Slots
Customizing Filter Protos
newtNumberFilter/newtIntegerFilter
newtDateFilter/newtSimpleDateFilter/newtDateNTimeFilter
Guide to Creating a Minimal NewtApp
Application Layer
Layout Layer
Overview
Non-overview
Entry Layer
Slot Layer
Install and Remove Scripts
What the Minimal NewtApp Will Do
What the Minimal NewtApp Won't Do
Examples
Bookstore Inventory
Replace Step 9
Replace Steps 18, 19, 20
Add Soup Support
Add Support for Date Find
Change Sort Order
Add a Custom Slot Proto
Exercises
Create a Simple NewtApp Application
Remember Current Sort Order When the Application Closes
Add Custom About Information
Summary
Stationery
What Is Stationery?
An Example of Stationery in the Notepad
An Example of Stationery in the Names Application
An Example of Stationery in the Out Box
Architecture of an Application that Supports Stationery
The Composition of Stationery
The dataDef
The viewDef
How Stationery Interacts with the System
Where Is Stationery Used?
Implementing Stationery
Data
dataDef Slots
Required Slots
Optional Slots
viewDef Slots
Required Slots
Optional slots
Registering and Unregistering Routines
Registering without NewtApp
Registering an Auto Part
Registering a Form Part
Registering with NewtApp
Protos Used with Stationery
Examples
Adding a New Kind of Data to the Notepad
Create the project
Create Constants
Create the dataDef
Create the viewDef
Create InstallScript and RemoveScript
Build and Test
Enhance the dataDef
Enhance the viewDef
Adding a New Editor to People in Names
Create constants
Create viewDef
The InfoFrame in the viewDef
InstallScript and RemoveScript
Build and Test
Making an Existing Application Stationery-Based
Create Constants
Create dataDef
Create viewDef
Deal with Stationery Registration
Change the Application to Take Advantage of the Stationery
Build and Test
Adding a New viewDef to a Stationery-Based Application
Add Show Button to Application
Create a Viewer viewDef
Troubleshooting
You tap on the New button and application breaks with "Expected an array, frame, or binary object, got nil"
You tap on the New button and your application only displays Note, Outline, and Checklist.
You choose an item from the New menu and the Newton throws an exception "Expected an array, frame, or binary object, got integer"
You choose an item from the New menu and get an error stating the stationery is not installed, with the dataDef name in parentheses.
You open your application and get an error that stationery is not installed. You notice the word "frame" is in parentheses.
You open your application and get an error that stationery is not installed. The weird thing is that the New button works fine.
You're extending another application, but your new data type doesn't appear in the New menu.
Exercises
Add Something to the Notepad
Add Another Kind of Data to Bookstore
Summary
Routing
An Overview of Routing
The Action Button
Route Scripts
The routeScripts Array
Adding a routeScripts Slot to a newtApp Application
Appending Ending Route Scripts to the Standard NewtApp Ones
Handling Multiple Items
Routing Formats
Introduction
Routing Formats--The Frame and Text DataTypes
Print/Fax Style
A Bit about Printing
Faxing
Adding Print and Fax Support to the Bookstore Application
Printing Multiple Items on a Page
Summary
NTK Reference
Using NTK
Choosing an AppleTalk Connection
NTK Menus
The File Menu
The Edit Menu
The Project Menu
The Layout Menu
The Browser Menu
The Window Menu
NTK Project Files
Adding Files to a Project
Add File
Add Window
Linked Layouts
NTK and Linked Subviews
Declaring and Linked Subviews
Using GetLayout
Creating a User Proto
Adding a User Proto to a Layout
Creating and Modifying Templates
Putting Templates in a Parent-Child Hierarchy
Moving and Changing Template Size Graphically
Naming Templates
Using Declare To on a Template
Removing Templates
The Browser
The Template Area of the Browser
Selecting Templates
The Template Hierarchy
The Slot List of the Browser
Editing an Existing Slot
Displaying a Slot's Values
Deleting and Renaming Slots
Adding Slots
The New Slot Dialog
After Scripts
The Slot Editor
The Apply and Revert Buttons
Types of Slots Editors
viewEffect
viewFormat
viewBounds
viewFlags
viewJustify
Additional Parts of Your Project
Text Files
Project Settings
Project Settings Dialog
Compile for Debugging
Ignore Native Keyword
Check Global Function Calls
NTK 1.0 Build Rules
Use stepChildren Slot
Suppress Bytecode
Compile for Profiling
Profile Native Functions
For Newton 2.0 Only
Faster Functions (2.0 only)
Tighter Object Packing (2.0 only)
Output Settings
Parts
Symbol
Name
Auto-Close
Icon File/Icon Name
Platform
Package Settings
Name
Delete Old Package on Download
Copy Protected
Auto Remove Package
Use Compression
Faster Decompression (2.0 Only)
Copyright
Version
Working with Part Frames
DeletionScript
Application Issues
Creating Unique Application Symbols and Names
Demo NTK
Differences between Demo NTK and NTK
Where to Go from Here
Apple's Associates and Partners Program for Newton
Newton Associates Program
Newton Associates-Plus Program
Newton Partners Program
Comp.Sys.Newton.Programmer
Newton Material on the Internet
The Australian Newton Developer Mailing List
Newton Material on CompuServe
PDA Developers Magazine
develop Magazine
Apple Developer Catalog
Newton Programming Classes
ViewFrame
Index

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

Last modified: 1 DEC 1996