Sample Code List - sorted by Category Updated 15 May 1995 NOTE: Sample code is written, blessed, and provided by Newton DTS and maintained by Bob Ebert. Please mail ebert@newton.apple.com orALink: EBERT if you would like to comment, request, submit, or otherwise chat about sample code. DTS does not necessarily guarantee lack of bugs and/or suitability of samples for home use. The sample code provided by DTS should run and have some reasonable level of documentation, and will generally illustrate an important point about Newton programming, but should not be viewed as the correct or ideal approach for all occasions. Design issues vary from application to application, and (good as they are) the DTS engineers occasionally make mistakes. Sample code is on ftp.apple.com in pie/newton/samples. Sample code is on the Apple engineering net in EtherKnott:ES´Newton Software Sample code is on AppleLink, spread around the appropriate sub-folders, in: Newton:PIE Developer Info:Newton:Technical Information:... GoodForm v4- by PIE DTS for Newton ToolKit 1.5 category: Application Design keywords: soup, filing, routing, Connection Kit, delete, find description: This application is the basic template for creation of data logging applications. It will store and retrieve records from a soup, also beam, find, use Newton Connection kit and file the entries. True Grid v3- by Bob Ebert for Newton ToolKit category: Application Design keywords: Grid View, Drawing, columns, proto, performance description: Implements three different ways to do scrolling "grid" views based on soup data, and evaluates the complexity and performance tradeoffs of each. pseudoInspector v2-3/1/94 by Todd Courtois for Newton ToolKit 1.5 category: Communications keywords: serial, comms, "inspector" description: This sample takes the SerialProtocol sample of Kent Sandvik one step further by implementing a very primitive Inspector. Strings that are sent to the newton (using the same method as in SerialPro) are processed kinda like in the Inspector or Inspector Gadget. Version 2 cleans out Print statements and resizes properly. SuperSlurp v1-7/11/94 by Jim Schram, Todd Courtois, ZZ, Kent Sandvik for Newton ToolKit category: Communications keywords: soup, serial MNP endpoint, connection to PC or Mac description: SuperSlurp sucks soup data down from a Mac via a serial endpoint, then stuffs it into a soup. SuperSlurp has the capability of creating soups which are currently non-resident on the Newton at runtime, by command of the Mac. SuperSlurp uses SERIAL MNP at 57600 bps. Must have the Apple Modem CTB Tool which comes with NTK to use it. Stuffs entries into the soup much much faster than old Slurp, also transfers data much faster and more reliably with MNP. IR Remote Sample v2-7/11/94 by Mike Cremer & Kent Sandvik for Newton ToolKit 1.5 category: Communications keywords: Communications endpoint IR remote control description: This sample shows how to make use of the specific IR functions for controlling consumer electronics applications. See the Q&A Communication sample for technical details. Note that the RC5.r file has resources for controlling Philips devices, and the Sony.r file has resource definitions for Sony consumer electronics products. You need to contact various other consumer electronics companies for more infomation about their IR protocols. Modem Setup v1-2/24/95 by Jim Schram for Newton ToolKit category: Communications keywords: Communications, Modem, Installer description: Complete installer shell to build custom modem setups for use by the modem enabler system extension. ADSP Sample v3- by Mike Cremer, Randy Carr, Kent Sandvik, Jim Schram for Newton ToolKit category: Communications keywords: ADSP, endpoint, communications, AppleTalk description: This example shows how to use the AppleTalk/ADSP endpoints. You can use the MacOS CommToolbox and a terminal emulator for talking with a Newton device. ACME Modem v3- by Jim Schram for Newton ToolKit category: Communications keywords: Communications, Modem, ASync, EndPoints description: Shows how to properly handle an asynchronous connect/disconnect cycle, with retries, one method of handling -18003 buffer overruns, how to prevent your endpoint exception handler from thrashing, how to avoid the FlushOutput nested event loop problem, and a work-around for the kCMOModemDialing options bug. ACME Serial v3- by Jim Schram for Newton ToolKit category: Communications keywords: Communications, Serial, ASync, EndPoints description: This sample is a modified version of the ACME Modem sample for use with serial endpoints. This shows how to properly handle an asynchronous connect/disconnect cycle, how to use the retry mechanism to automatically switch between ports, one method of handling -18003 buffer overruns, how to prevent your endpoint exception handler from thrashing, how to avoid the FlushOutput nested event loop problem, and a work-around for the kCMOModemDialing options bug. LlamaTalk v3- by Jim Schram for Newton ToolKit category: Communications keywords: LlamaTalk LlamaShare AppleTalk ADSP MNP Echo Server State Machine description: Everything you ever wanted to know about making ADSP work in Newton OS 1.3 and earlier (don't taunt the ADSP endpoint...) This is a HUGE two-part sample comprised of both Newton & Mac code. The Newton component is a simple front-end which demonstrates sending and receiving transactions of various data types. It makes calls to a protoLlamaTalk user proto which is an encapsulation of EVERYTHING needed to handle ADSP and MNP communications reliably. The Mac component is a simple back-end which receives transactions and echos back a "hex dump" of the transaction data. It makes calls to a robust multiple-client communications library built on top of the Mac CommToolBox. ALL I/O is asynchronous and interrupt-driven. The library uses no globals and can be called from within an Application, Control Panel, Init, XCommand, 4D External, etc. etc. Release 3 incorporates NO changes to the Mac components. The Newton Component 1.0a8 now compiles with NTK 1.5 build rules. IRTimeSync v4- by Jim Schram for Newton ToolKit 1.5 category: Communications keywords: IR Beam Time Synchronization State Machine Timeout description: Synchronize the date-time clocks of two Newtons via IR beaming. Demonstrates: 1. Clock synchronization to +/- one second. 2. Using SharpIR beaming protocol with strings. 3. Simple state machine. 4. Asynchronous Connect(). 5. Handling time-outs. 6. Synchronous SysBeep(). IRSample v3- by Mike Cremer & Randy Carr & Kent Sandvik for Newton ToolKit 1.5 category: Communications keywords: Communication, IR, InfraRed, endpoint description: This sample shows how to make use of the IR endpoints, also how to write IR protocol applications. Built-In MetaDatas v2-1/18/95 by Peter Alley for Text category: Connection Kit keywords: MetaData, Newton Connection, Built In Apps description: These are the updated MetaDatas for the built in Names and Card File applications for Newton Connection 2.0. They illustrate the validation and multiple-export script features of Connection 2.0. (They won't be found in the Newton, since they're encapsulated inside Newton Connection.) Sync Another One v3-1/18/95 by Bob Ebert for Newton ToolKit category: Connection Kit keywords: Newton Connection, Macintosh, PC, Windows, MetaData, Soup, Store, User Interface description: Illustrates how to write (and TEST) Newton Connection MetaData. Soup Tour v3- by David Levy & Kent Sandvik for Inspector/Listner category: Data Storage (Soups) keywords: Soup index entries stores Query Cursor description: This is a simple walkthrough of many store and soup functions, including queries and smart index tricks. Check this out using an Inspector Window. Beyond Help v4- by Bob Ebert & Maurice Sharp for Newton Book Maker category: Digital books keywords: Help Book, Dickens, Tiny Tim, How Do I description: Illustrates creation and usege of a custom help book. BookSample v3- by Bob Ebert for Newton Book Maker category: Digital books keywords: Digital Books, Dickens, Copperfield, Book Maker, Book Reader, Users Guide description: A sample book source--the Newton Book Maker User's Manual in Newton Book Reader form. Different Strokes v2-9/15/93 by Bob Ebert for Newton ToolKit 1.5 category: Drawing keywords: Drawing, viewClickScript, ink description: demonstrates how to capture ink and turn it into drawing objects for rendering on the screen, saving, etc. Font Scaling v3-9/15/93 by Bob Ebert for Newton ToolKit 1.5 category: Drawing keywords: drawing, font, scaling, pict, word, dictionary description: Demonstrates how to scale fonts. Not as simple as you might think at first... you have to put a text shape into a PICT shape and scale that. There are some clipping concerns as well. Up In Smoke v3313-10/1/93 by Mike Engber for Newton ToolKit category: Drawing keywords: Smoke, Clouds, Poof, Drawing, CopyBits, modeMask description: Shows how to achieve the ever popular smoke/poof/scrub effect. Also illustrates scaling with CopyBits, using modeMask with CopyBits, and using BuildContext to force an update of an area of the screen. Hand Crank v3- by Todd Courtois for category: Drawing keywords: scrolling, AddArraySlot, RemoveSlot, MakeText, DrawShape, viewIdleScript description: Shows how one can do fast text drawing by hand. Simple blasts an array of text lines to a clView. Does no wrapping, but scrolls. Calls to GetRandomWord() could be replaced by useful text-formatting routines to take your gobs of text and get it onscreen quickly. Important for things like terminal emulators. IdleScript Anime v3- by Todd Courtois for Newton ToolKit category: Drawing keywords: IdleScript drawing, animation, PlaySound and drawing speed effects, protoIconButton description: This app contains four similar clViews which execute simple animation in their idleScripts. Dot2Dot v3- by Kent Sandvik for Newton ToolKit category: Drawing keywords: view points polygon description: Demonstrates the following: ´ mapping global coordinates to local ones ´ tracking pen clicks and convert them to an array suitable for a polygon ´ view system handling ´ creating arrays in RAM ´ dynamically changing a clPictureView's icon slot Drawing v3- by Bob Ebert for Newton ToolKit 1.5 category: Drawing keywords: drawing, polygon, line, point, rectangle, style, font, pict, shape description: Demonstrates functions in drawing chapter, shows how to make shapes and display them, as well as how to offset the shapes. MonacoTest v4- by Bob Ebert & J. Christopher Bell for Newton ToolKit 1.5 category: Drawing keywords: Fonts monospaced nonproportional printing install package monaco courier description: This sample provides a mono-spaced font for use on the Newton (Monaco 9pt) and gives a short demonstration of how to use it on screen and in printing. The most recent font package can substitute courier for monaco when printing to a PostScript printer which contains the necessary fonts. Now shows how to create packages that will install a font only if necessary. IA Tour v3-2/28/94 by Bill Luciw for Inspector/Listner category: Intelligent Assistant keywords: Intelligent Assist, action template, target template, task template description: This is code used during the Newton Developer Conference-93, Intelligent Assist presentation. Version 2 fixes a couple of bugs that prevented straight through allocation. It needs a README with some explanation (from the slides.) SoupShow v2-12/22/93 by Maurice Sharp for Newton ToolKit category: Miscellaneous (Other) keywords: views, application design, display data, data description: This multi-part sample shows how to display data without all the noise of creating soups. It displays the names from the names file. It has 2 parts, a simple implementation that just has an individual item view and scrolls through names. It also has a more complex sample that does an overview as well. Full step by step readmees make this a happy happy joy joy experience Checkbook v4- by Neil Rhodes & PIE DTS for Newton ToolKit 1.5 category: Miscellaneous (Other) keywords: Application, Find, Filing, IA, Views, Soups, Connection description: Full application example. It supports routing, filing, IA and Newton Connection. See the README for more info. Extra Change v3- by Mike Engber for Newton ToolKit category: Miscellaneous (Other) keywords: SetExtrasInfo Extras Drawer Icon description: This sample app changes it's icon(and text) in the Extras drawer when you tap it. Inspector Gadget v3- by Bob Ebert & Ando Moon for Newton ToolKit 1.5 category: NewtonScript keywords: Compile, NewtonScript, Hack, Evaluate description: demonstrates using the ñCompileî function to write newtonscript from the newton itself. Code on the plane... Buttons v4-7/11/94 by Maurice Sharp & Kent Sandvik for Newton ToolKit 1.0.1 category: Protos keywords: protoTextButton, button, drag, protoShowBar, Popup, DoPopup, PictureButton description: Show how to do various things using buttons, we have three examples: 1) Use DoPopup to create a popup menu. 2) Show how to place a group of buttons inside a view that could be dragged 3) Show how to draw small pictures inside a button itself. 4) Shows how to do a fake protoShowBar style button Gauges v2-2/28/94 by Kent Sandvik for Newton ToolKit category: Protos keywords: protoGauge max min protoLabelinputline description: the Gauges sample shows the following techniques: ´ How to use a protoGauge ´ How to change the max (or min) values of a gauge dynamically ´ How to tie together this with smart use of a protoLabelInputLine Glancing v2-2/28/94 by Kent Sandvik for Newton ToolKit category: Protos keywords: protoGlance, protoLabeledBatteryGauge, protoPictureButton description: Demonstrates a few system protos. ´ Show how protoGlances work ´ Has a protoLabeledBatteryGauge inside the Glance ´ Shows how protoPictureButtons work Pict Buttons v2-2/28/94 by Maurice Sharp for Newton ToolKit category: Protos keywords: icon, PICT resource, Masks, pictures description: illustrates: 1. How you can change the icon of a picture button 2. Two ways to get Newton pictures from PICT resources 3. The use of picture Masks protoa2z_TDS v5- by Maurice Sharp for Newton ToolKit category: Protos keywords: proto, protoPictIndexer description: protoa2z_TDS gives you the functionality of the A to Z index in the overview of the Cardfile. It's a user proto based on a proto in the ROMs. protoTable v2-2/28/94 by Maurice Sharp & Bob Ebert for Newton ToolKit category: Protos keywords: protoTable, proto, lists, scroll description: demonstrates the protoTable. Does scrolling and on the fly updating based on the selected example. Rec Toggle v2-2/28/94 by Maurice Sharp for Newton ToolKit category: Protos keywords: proto, recognition description: Demos the recognition toggle button (as used in the notepad...). Phone Expando v2-9/15/93 by Maurice Sharp for Newton ToolKit category: Protos keywords: protoExpandoShell, proto description: Demonstrates a text expando with phone list style drop downs etc. Similar to phone input lines from the cardfile. PictIndex v1-9/15/93 by Maurice Sharp for Newton ToolKit category: Protos keywords: proto, protoPictIndexer, pictures description: Demonstrates using protoPictIndexer, which allows you to specify a large picture as a series of selectable small pictures. Keys v3-2/28/94 by Maurice Sharp, J. Christopher Bell for Newton ToolKit category: Protos keywords: key, protoKeyboard, protoKeypad, clKeyboardView description: This shows how to do a keyboard, including using a picture for a keycap and using strings for what the key prints out. The new version shows one of the keys which will 'modify' the visual and output components of another key. Shell Game v3-4/22/94 by Maurice Sharp for Newton ToolKit category: Protos keywords: protoExpandoShell, proto description: this little thing shows how to keep 2 shells that are side by side in sync. Kind of stupid, but you never know :-) Number Expando v2-10/7/93 by Maurice Sharp for Newton ToolKit category: Protos keywords: proto, protoExpandShell, expando description: shows how to create an expando item that takes and displays numbers. Provides a proto for people to use. Uses the setup2() messages. Expando Time v3-3/7/94 by Giovanna Ostacchini & Maurice Sharp for Newton ToolKit category: Protos keywords: Time, date, protoExpando, expando shell description: A custom expando item that edits a time. Shows how to create a custom expando item based on protoTextExpando DynaPicker v2- by Todd Courtois for Newton ToolKit 1.5 category: Protos keywords: protoLabelPicker description: Shows how to dynamically change the items in a protoLabelPicker. Radio Cluster v3- by Kent Sandvik for Newton ToolKit category: Protos keywords: protoradiobutton, protoRadioCluster description: demonstrates a radio button cluster. ´ Shows how radio clusters and radiobuttons work ´ Shows how to extract info from the radio cluster ´ Shows some fun with view transition effects TextList v3- by Kent Sandvik for Newton ToolKit category: Protos keywords: protoTextList description: Shows how protoTextList operates. Tables and Lists v3- by Todd Courtois for Newton ToolKit category: Protos keywords: protoTable, protoTextList, protos description: Small demo of protoTable and protoTextList. Shows how you can do toggle selections on items (i.e., click once to select, then again to deselect), shows how you can do your own stuff when clicks happen (trivial in protoTextList, skanky in protoTable). QWERTY v2- by J. Christopher Bell and Maurice Sharp for Newton ToolKit category: Protos keywords: keyboard, qwerty, protoKeypad, protoKeyboard description: The QWERTY project shows how to implement an on-screen keyboard which does not prompt for "add-to-dictionary?" or have the "dictionary" icon. This sample project creates a keyboard which looks like the American QWERTY keyboard.