TweetFollow Us on Twitter

March 96 - Newton Q & A: Ask the Llama

Newton Q & A: Ask the Llama

Q Now that Newton 2.0 is shipping, what has changed?

A A fair question, and one that's been much on my mind. Newton 2.0 solves some of the problems previously presented in this column in much better ways. So I've gone back over old questions to see what has changed. I'll start out this time by revisiting those questions that have new answers. (Questions that dealt with subsystems whose APIs on the Newton 2.0 OS are drastically different will not be covered; most of these have to do with routing, which has undergone a significant change for the better, while some have to do with communications.)

Q How do I create my own class of binary object? (Issue 18)

A In the Newton 1.x OS you had to use SetClass on a string object to make some other binary object. In 2.0 you can just call the new function MakeBinary. So the line of code to define the canonical CharID object (see the original answer) changes to

DefConst('kDefaultCharIDOBj, MakeBinary(4, 'CharID)); 
Q I would like to add a [button|view|Llama] to [Notes|Dates|Names| etc.]. How can I do that safely? (Issue 19)

A In the Newton 1.x OS there was no supported way to add items to the built-in applications. In 2.0 there are a few ways you can do this.

For general changes, you can add new stationery to Notes, Dates, and Names. For example, you could add graph paper to Notes. You could also define new card styles or views of a person in Names.

Names and Dates also let you add whole new classes of things. For instance, you could add a Pet type of names entry that would appear in the New pop-up menu along with Person, Company, and Group.

The Dates application has an API to add new types of meetings. It also lets you add items to its Info button.

In addition, there's a general API to register buttons that can show up in the "blessed" application's status bar. It's up to each application to decide whether and how it will display registered buttons. You should no longer use the unsupported keyboardChicken hack.

Note that on the Newton 2.0 platform there's still no support for adding buttons to built-in slips. For example, if you wanted to add something to the alarm picker for a meeting, you would need to add a new type of stationery that's a superset of the alarm picker.

Q I've written my own IsASCIIAlpha, IsASCIINumeric, etc. functions. They seem to be really slow. Why is that? Here's my IsASCIIAlpha: [code not repeated here; all the functions work on strings] (Issue 20)

A Most of the comments from the original answer still hold. However, in the Newton 2.0 OS the string could be a rich string; that is, there could be an ink character inside the string. That means the compare functions have to check whether a particular character was kInkChar.

Q When I try to add an index to my soup I sometimes get an exception -48019, but not always. What's going on? (Issue 22)

A In early versions of Newton, if you added an index on a slot, and an entry in that soup had a value of nil for that slot, you would get an error. As of the Newton 2.0 OS this is no longer a problem. You can add an index even if there are entries with nil values for the slot in the soup.

Q I have an application that uses ADSP to connect to a server on the desktop. I want the server to handle multiple Newton devices connected simultaneously. Unfortunately, if a connection fails after it's opened, the server doesn't seem to be able to identify it as a new connection when the Newton device reconnects. This causes problems in the server's ability to handle multiple connections. Can you help? (Issue 23)

A In the Newton 2.0 OS this no longer occurs. The Newton device will generate a new ID for the connection.

Q Since there are changes between Newton 1.x and 2.0, what features in 2.0 can I rely on? What is the core set that defines Newton 2.0?

A At this time there is no published core set of NewtonScript-level features that you can rely on. We're confident that you can rely on the features of the NewtonScript language and major components like the view system and communication endpoint interface. However, you can't count on individual protos or even the internal applications being there. Since we license Newton technology to other companies, they could produce a Newton device that doesn't include Names, Dates, or other built-in features. They may also produce Newton devices that have features that aren't present in Apple products.

The key is to test the features you rely on. If you find that some of the features you need are missing, you can either run in a less-featured mode or just not open your application. As a simple example, suppose your application runs only in a limited set of screen sizes and aspect ratios. You can give your base application view a viewSetupFormScript that looks something like this:

myBaseView.viewSetupFormScript := func()
begin
    local screenSize := GetAppParams();
    local aspectRatio := screenSize.appAreaWidth / 
                                screenSize.appAreaHeight;

    // very simplistic test, no MINIMUM even!
    if aspectRatio > 1.0 then    // landscape
    begin
        local maxHeight := kMaxAppWidth;
        local maxWidth := kMaxAppHeight;
    end;
    else begin                      // portrait or square
        local maxHeight := kMaxAppHeight;
        local maxWidth := kMaxAppWidth;
    end;

    if screenSize.appAreaWidth <= maxWidth AND
        screenSize.appAreaHeight <= maxHeight then
    begin
        self.viewBounds := RelBounds(...);
        // other setup stuff
        ...
    end
    else begin
        // cannot operate at screen size
        :Notify(kNotifyAlert, EnsureInternal(kAppName),
            EnsureInternal(kErrorWrongScreenSize));
        AddDeferredSend(self, 'Close, nil);
    end;
end;
For global functions and variables, you can use the GlobalFnExists and GlobalVarExists utility functions. To find out whether a built-in application exists, you can check the root view with the appropriate symbol:
// check for Dates
if GetRoot().calendar then
    ...
// check for Names
if GetRoot().cardfile then
    ...
// check for Extras
if GetRoot().extrasDrawer then
    ...
For protos, you can try to access the proto and catch a frame reference exception. If the exception occurs, the proto is not present.

In general, it's a wise idea to do all your existence testing as your application is launching. Set flags in your base application so that you test for existing features only once.

Q Is there a hardware-unique ID that I can access on a Newton device?

A At this time there's no built-in hardware-unique ID, nor is there an API for accessing one if it existed. However, this doesn't rule out having such an API in future Newton devices.

Q I'm using a Newton 2.0 protoSoupOverview and I want to change the font style. How do I do that?

A This is one of those things that are obvious once you make the connection. You use the Abstract method of protoSoupOverview (and protoOverview, for that matter) to build the shape that's displayed for a particular soup entry. Notice that you're returning a shape, with all that entails. The chapter on drawing in the Newton Programmer's Guide says you can include a styles entry in a shape array, allowing you to specify things like font style. See the DTS Sample Code Checkbook on the Newton Developer CD for an example.

Q I noticed that some of the built-in applications have keyboards in their slips -- for example, the new name editor in the Names file. Is this stationery based? Is there a magic slot I can set? Is there a proto?

A Those keyboards are just views based on protoKeypad that are laid out as a child view of the slip. All you need to do is lay out your own protoKeypad and set up the definitions appropriately. There is no supported magic slot.

Q I'm trying to use a protoListPicker to display a soup structure that has nested frame entries. I can't get the listPicker to work. Am I doing something wrong?

A No. The default listPicker proto doesn't work with items that are accessed via path expressions. However, if you make the following three changes, your listPicker should work fine.

First, you have to specialize the GetObjSlot method of your pickerDef:

GetObjSlot: func(item, fieldPath)
begin
    if ClassOf(fieldPath) <> 'pathExpr then
        // if not a path expression, return the inherited value
        return inherited:GetObjSlot(item, fieldPath);

    // otherwise, if there is no item, return nil
    if not item then
        return nil;

    // there is an item, so get the real value, since the item
    // could be a NameRef or an Entry
    if IsNameRef(item) then
        local val := EntryFromObj(item);
    else
        val := item;

    // assuming we have a real thing, access the real data via the
    // path expression in fieldPath
    if val then
        val.(fieldPath);
end
Second, if you specify a validation frame in for your listPicker, the nesting of that frame must match the nesting of your soup entry.

Finally, modify your pickerDef so that the column that displays the data based on the index path uses the appropriate index path.


The llama is the unofficial mascot of the Developer Technical Support group in Apple's Newton Systems Group. Send your Newton-related questions to NewtonMail or eWorld DRLLAMA or to AppleLink DR.LLAMA. The first time we use a question from you, we'll send you a T-shirt.*

Thanks to our Newton Partners for the questions used in this column, and to jXopher Bell, Henry Cate, Bob Ebert, David Fedor, Jim Schram, Maurice Sharp, and Bruce Thompson for the answers.*

If you need more answers, check out http://dev.info.apple.com/newton on the World Wide Web or look at Newton Developer Info on AppleLink.*

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Make the passage of time your plaything...
While some of us are still waiting for a chance to get our hands on Ash Prime - yes, don’t remind me I could currently buy him this month I’m barely hanging on - Digital Extremes has announced its next anticipated Prime Form for Warframe. Starting... | Read more »
If you can find it and fit through the d...
The holy trinity of amazing company names have come together, to release their equally amazing and adorable mobile game, Hamster Inn. Published by HyperBeard Games, and co-developed by Mum Not Proud and Little Sasquatch Studios, it's time to... | Read more »
Amikin Survival opens for pre-orders on...
Join me on the wonderful trip down the inspiration rabbit hole; much as Palworld seemingly “borrowed” many aspects from the hit Pokemon franchise, it is time for the heavily armed animal survival to also spawn some illegitimate children as Helio... | Read more »
PUBG Mobile teams up with global phenome...
Since launching in 2019, SpyxFamily has exploded to damn near catastrophic popularity, so it was only a matter of time before a mobile game snapped up a collaboration. Enter PUBG Mobile. Until May 12th, players will be able to collect a host of... | Read more »
Embark into the frozen tundra of certain...
Chucklefish, developers of hit action-adventure sandbox game Starbound and owner of one of the cutest logos in gaming, has released their roguelike deck-builder Wildfrost. Created alongside developers Gaziter and Deadpan Games, Wildfrost will... | Read more »
MoreFun Studios has announced Season 4,...
Tension has escalated in the ever-volatile world of Arena Breakout, as your old pal Randall Fisher and bosses Fred and Perrero continue to lob insults and explosives at each other, bringing us to a new phase of warfare. Season 4, Into The Fog of... | Read more »
Top Mobile Game Discounts
Every day, we pick out a curated list of the best mobile discounts on the App Store and post them here. This list won't be comprehensive, but it every game on it is recommended. Feel free to check out the coverage we did on them in the links below... | Read more »
Marvel Future Fight celebrates nine year...
Announced alongside an advertising image I can only assume was aimed squarely at myself with the prominent Deadpool and Odin featured on it, Netmarble has revealed their celebrations for the 9th anniversary of Marvel Future Fight. The Countdown... | Read more »
HoYoFair 2024 prepares to showcase over...
To say Genshin Impact took the world by storm when it was released would be an understatement. However, I think the most surprising part of the launch was just how much further it went than gaming. There have been concerts, art shows, massive... | Read more »
Explore some of BBCs' most iconic s...
Despite your personal opinion on the BBC at a managerial level, it is undeniable that it has overseen some fantastic British shows in the past, and now thanks to a partnership with Roblox, players will be able to interact with some of these... | Read more »

Price Scanner via MacPrices.net

You can save $300-$480 on a 14-inch M3 Pro/Ma...
Apple has 14″ M3 Pro and M3 Max MacBook Pros in stock today and available, Certified Refurbished, starting at $1699 and ranging up to $480 off MSRP. Each model features a new outer case, shipping is... Read more
24-inch M1 iMacs available at Apple starting...
Apple has clearance M1 iMacs available in their Certified Refurbished store starting at $1049 and ranging up to $300 off original MSRP. Each iMac is in like-new condition and comes with Apple’s... Read more
Walmart continues to offer $699 13-inch M1 Ma...
Walmart continues to offer new Apple 13″ M1 MacBook Airs (8GB RAM, 256GB SSD) online for $699, $300 off original MSRP, in Space Gray, Silver, and Gold colors. These are new MacBook for sale by... Read more
B&H has 13-inch M2 MacBook Airs with 16GB...
B&H Photo has 13″ MacBook Airs with M2 CPUs, 16GB of memory, and 256GB of storage in stock and on sale for $1099, $100 off Apple’s MSRP for this configuration. Free 1-2 day delivery is available... Read more
14-inch M3 MacBook Pro with 16GB of RAM avail...
Apple has the 14″ M3 MacBook Pro with 16GB of RAM and 1TB of storage, Certified Refurbished, available for $300 off MSRP. Each MacBook Pro features a new outer case, shipping is free, and an Apple 1-... Read more
Apple M2 Mac minis on sale for up to $150 off...
Amazon has Apple’s M2-powered Mac minis in stock and on sale for $100-$150 off MSRP, each including free delivery: – Mac mini M2/256GB SSD: $499, save $100 – Mac mini M2/512GB SSD: $699, save $100 –... Read more
Amazon is offering a $200 discount on 14-inch...
Amazon has 14-inch M3 MacBook Pros in stock and on sale for $200 off MSRP. Shipping is free. Note that Amazon’s stock tends to come and go: – 14″ M3 MacBook Pro (8GB RAM/512GB SSD): $1399.99, $200... Read more
Sunday Sale: 13-inch M3 MacBook Air for $999,...
Several Apple retailers have the new 13″ MacBook Air with an M3 CPU in stock and on sale today for only $999 in Midnight. These are the lowest prices currently available for new 13″ M3 MacBook Airs... Read more
Multiple Apple retailers are offering 13-inch...
Several Apple retailers have 13″ MacBook Airs with M2 CPUs in stock and on sale this weekend starting at only $849 in Space Gray, Silver, Starlight, and Midnight colors. These are the lowest prices... Read more
Roundup of Verizon’s April Apple iPhone Promo...
Verizon is offering a number of iPhone deals for the month of April. Switch, and open a new of service, and you can qualify for a free iPhone 15 or heavy monthly discounts on other models: – 128GB... Read more

Jobs Board

Relationship Banker - *Apple* Valley Financ...
Relationship Banker - Apple Valley Financial Center APPLE VALLEY, Minnesota **Job Description:** At Bank of America, we are guided by a common purpose to help Read more
IN6728 Optometrist- *Apple* Valley, CA- Tar...
Date: Apr 9, 2024 Brand: Target Optical Location: Apple Valley, CA, US, 92308 **Requisition ID:** 824398 At Target Optical, we help people see and look great - and Read more
Medical Assistant - Orthopedics *Apple* Hil...
Medical Assistant - Orthopedics Apple Hill York Location: WellSpan Medical Group, York, PA Schedule: Full Time Sign-On Bonus Eligible Remote/Hybrid Regular Apply Now Read more
*Apple* Systems Administrator - JAMF - Activ...
…**Public Trust/Other Required:** None **Job Family:** Systems Administration **Skills:** Apple Platforms,Computer Servers,Jamf Pro **Experience:** 3 + years of Read more
Liquor Stock Clerk - S. *Apple* St. - Idaho...
Liquor Stock Clerk - S. Apple St. Boise Posting Begin Date: 2023/10/10 Posting End Date: 2024/10/14 Category: Retail Sub Category: Customer Service Work Type: Part Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.