http://www.newton-inc.com/dev/techinfo/qa/qa.htm
protoFormulasPanel
for RegFormulas
, but there does not appear to be such a template.protoFloatNGo
as your base and add your formula elements to it. The only requirements are:overview
slot that contains the text to show in the formula's overview.viewbounds.bottom
must be the height of your panel.protoTitle
whose title
slot is the name of the formula panel.RegPrefs
function.protoPrefsRollItem
is incomplete. You must define an overview
slot which is the text to show in the overview mode. You can optionally define an icon
slot which is an icon for the title in the non-overview mode (a title icon). Note that title icons are much smaller than normal icons.SetEntryAlarm
calendar message, but the alarm is not set.SetEntryAlarm
will not find events. You need to use a new Calendar API called SetEventAlarm
. This function is provided in the Newton 2.0 Platform File. See the Platform File Notes for more information.AddLayout
method requires that the symbol in the layout is internal. This bug will be fixed in a future ROM. To work around this, do the following:local newLayout := {_proto: GetLayout("A Test Layout")};
newLayout.symbol := EnsureInternal (newLayout.symbol);
GetRoot().cardfile:AddLayout(newLayout);
For more information about issues for applications running from a PCMCIA card, see the article "The Newton Still Needs the Card You Removed"CircleDistance
which takes two longitude/latitude pairs and the units to use in reporting the distance, and CircleDistance
returns the distance between the two points. NTK may give a warning about "Unknown global function 'CircleDistance'
". This warning can be safely ignored so long as you're writing a package for a Newton 2.0 OS device.CircleDistance
(firstLong, firstLat, secondLong, secondLat, units)CircleDistance
rounds the distance to the nearest ten miles or ten kilometers. firstLong
: The longitude for the first point on the Earth. firstLat
: The latitude for the first point on the Earth. secondLong
: The longitude for the second point on the Earth. secondLat
: The latitude for the second point on the Earth. units
: A symbol specifying the units in which the distance will be calculated. Currently the options are 'miles
or 'kilometers
.NewCity
. Check the section titled "Using the Time Zone Application" in the Built-In Applications and System Data chapter of the Newton Programmer's Guide for information on how to convert a longitude or latitude in degrees, minutes & seconds to an integer for CircleDistance
.GetExtraIcons
result in an undefined Query
method exception. How can I fix this?GetExtraIcons
. The code is not checking if the store has any extras information on it, so the Query
message is getting sent to a NIL
soup. The result is the exception.GetExtraIcons
: try
GetExtraIcons(...)
// do whatever you need to do here
onexception |evt.ex.fr.intrp;type.ref.frame| do
begin
// check for a problem calling the Query function
if currentException().data.errorCode = -48809 AND
currentException().data.symbol = 'Query then
begin
// no extras drawer info on the store
end ;
else
// a real error has occured, so let system handle it
ReThrow() ;
end ;
bcCustomFields
returns the labels and values of the custom fields used in the entry. Is there a way to get a list of all the custom fields the user has defined?'customFields
to the names soup method GetInfo
. This will return a frame of all the custom fields the user has defined. Each slot in this frame will have a frame with a 'label
slot. Each 'label
slot will be a string specified by the user. Here is an example:
GetStores()[0]:GetSoup(ROM_CardFileSoupName):GetInfo('customFields)
...which returns:{custom1: {label: "Customer Label"},
custom2: {label: "Another label"}}
owner
slot, the value of which is a frame. This slot is removed from the entry before it is sent to another Newton device. You can add slots to this frame to store them, but keep them from being sent. Be sure to append your developer signature to any slot names you add to the owner
frame.MakeTextNote
doesn't work if Notes is closed.MakeTextNote
to create the data, then add it to the soup entry using soup:AddXmit
or uSoup:AddToStoreXmit
(or one of the other soup functions.)MakeTextNote
always creates a frame with all the correct data that the Notes application requires. If the 2nd paramater (addit) is TRUE
, it will add that frame to the Notes soup and show the note on the screen. If addIt is NIL
, then the frame is returned. newNote := GetRoot().paperroll:MakeTextNote("Here is a sample note", nil);
GetUnionSoup("Notes"):AddToDefaultStoreXmit(newNote, '|appSym:SIG|)
tapAction
slot but it does not work. What is missing?tapAction
slot if it does not find a 'text
slot in the partFrame
as well. The 'text
slot contains the name that will be displayed in the Extras drawer.tapAction
to a your part frame (in other words, your autopart): DefineGlobalConstant('kTapActionFn,
func()
begin
// your code goes here!
end);
// part MUST have a text slot for tapAction to be used
// text slot is the name seen by the user in Extras
SetPartFrameSlot('text, kAppName) ;
SetPartFrameSlot('tapAction, kTapActionFn) ;
GetAppPrefs
to get the prefs for that application for read-only purposes. Only the documented slots in that frame should be accessed. Other slots are neither documented nor supported, and their behavior may change. You should also check to ensure that the Home Page application exists on a particular unit before using any features. For example, here is a code snippet that evaluates to an array of user names, or NIL if the unit does not support multiple users or is not in multi-user mode. if GetRoot().HomePage then
begin
local prefs := GetAppPrefs('HomePage, '{});
if prefs.users and prefs.kMultipleUsers then
foreach item in prefs.users collect item.name;
end;
kMultipleUsers
: non-nil if multi-user mode is enabledkRequirePassword
non-nil if passwords required in multi-user modekDisallowNewUsers
non-nil if new users can't be created at loginusers
array of user frames or NIL.name
a string, the user-visible user's nameRegUserConfigChange
and watching for the 'kCurrentUser
slot to change will let you catch changes to the current set of multi-user names.RegAuxButton
, I get a -48204 error. Why am I getting this error? try
RegAuxButton( kAppSymbol, {destApp: 'newtWorks, ...} );
onexception |evt.ex.fr| do
nil;
AddEntryFromStationery
. For instance: if GetRoot().NewtWorks then
GetRoot().NewtWorks:AddEntryFromStationery(stationerySym);
AdoptEntryFromStationery
. To create a new entry, you must add the basic Newton Works soup entry slots and then any stationery-specific slots:class
: Class of the item. For instance, for Draw documents, use the symbol 'drawPaper
version
: Integer, the current version of the entrytitle
: String which is the document titletimeStamp
: Creation date of the entryrealModTime
: Date the entry was most recently modifiedsaveData
: a frame with the following slots:shapes
: Required. An array of a single item, a picture as returned by the global function MakePict
. selection: [], // the empty array
styles: nil,
saveData
slot of Draw documents already in Newton Works should be treated as read-only. (Do not try to modify these data structures in any way.)SaveData
: the object returned from protoTXView:Externalize().
See the Newton 2.1 OS documentation for information about Externalize().
Note that this data must be from a protoTXView
that uses VBOs (it uses the protoTXView:SetStore(...)
method), or Newton Works can run out of NewtonScript memory when editing the document.hiliteRange
: frame with the document's hilite range (see the protoTXView
documentation for details)margins
: a frame with slots 'top
, 'left
, 'bottom
, 'right
, which are the document's margins in pixels. The frame can also optionally have the slots 'userTop
, 'userLeft
, 'userBottom
, and 'userRight
that will contain numbers (integer or real) with the margin sizes translated to user units (inches or centimeters.) If the userXXX
slots are missing or nil
, they will be calculated from the pixel values. if GetRoot().NewtWorks then
GetRoot().NewtWorks:AdoptEntryFromStationery(theEntry, stationerySym, GetDefaultStore());
See the Newton Programmer's Reference for more info about the NewtApplication:AdoptEntryFromStationery(...)
method.class
: Class of the item. For instance, for Draw documents, use the symbol 'drawPaper
version
: Integer, the current version of the entrytitle
: String which is the document titletimeStamp
: Creation date of the entryrealModTime
: Date the entry was most recently modifiedsaveData
that contains the following slots:shapes
: This is an array of shapes in the document.styles
: An array of all styles contained in the shapes array. selection
: An array containing integer indexes into the shapes array, indicating the currently selected shapes.shapes
slot is represented as an array of style/shape pairs, as returned by drawApp:GetContents()
. Each "shape" can be another array of shape and style pairs, representing grouping of shapes (these grouping can continue, so subarrays can have sub-subarrays, etc). If the shapes array contains exactly one item (its length is 1) and the class of the item is 'picture
, it is a picture that has been created/imported but not yet viewed in Newton Works. If this is the case, the individual shapes cannot be read, but the picture is the same format as the return value of the global function MakePict
.saveData
slot of Draw documents already in Newton Works should be treated as read-only. Do not try to modify these data structures in any way. Manipulating them can result in serious user problems.ShowFoundItem
method of the Works base view only as shown below. ShowFoundItem
is generally intended for internal use by the application itself. However, it provides handy access for navigating to a particular soup entry, so Works supports using it for this purpose only. Do not attempt to use ShowFoundItem
to do more than simply bring up an entry in the Works application.ShowFoundItem
may be difficult to specify because Works can use stationery provided by 3rd parties, which may have special requirements for the finder. In Works, the stationery is responsible for adding data to the finder when a find is performed, and so the stationery may rely on that data being present when ShowFoundItem
is later used. For all the stationery types that exist at the time this Q&A was written, a minimal finder frame of {findWords: [""]}
is sufficient to allow the stationery to show the item. Please note that this is NOT a fully specified finder, however it is sufficient for the FindSoupExcerpt
method, which is used widely. A full finder frame which accomplishes the same thing might look like this: {owner: GetRoot().NewtWorks,
findType: 'text,
findWords: [""],
items: [{_proto: theEntry, title: "None"}]}
ShowFoundItem
method. (Note that ShowFoundItem
is a Works-specific requirement of stationery. Generic ViewDefs do not require a ShowFoundItem
method.)
// make sure Works is open
GetRoot().NewtWorks:Open();
// find an entry
s := GetUnionSoup("NewtWorks");
theEntry := s:Query({text: "Untitled Paper"}):Entry();
// show it
GetRoot().NewtWorks:ShowFoundItem(e, {findWords: [""]});
// the rest of them
theEntry := s:Query({text: "Untitled Drawing"}):Entry();
GetRoot().NewtWorks:ShowFoundItem(e, {findWords: [""]});
theEntry := s:Query({text: "Untitled Calculations"}):Entry();
GetRoot().NewtWorks:ShowFoundItem(e, {findWords: [""]});
theEntry := s:Query({text: "Untitled Spreadsheet"}):Entry();
GetRoot().NewtWorks:ShowFoundItem(e, {findWords: [""]});
// cleanup
theEntry := s := nil;
MakeTextNote
function.protoTXView
. Use the protoTXView
methods to add data to that view. When done, use the Externalize
method to get the data in a form suitable for saving in the Works soup.protoTXView
, it's imperative that you call the SetStore
method so that the data is created on the user store rather than the NS heap. Different formats are used for store-backed and heap-backed protoTXViews
, and the type of backing is carried into the Externalized
data. As a result, failure to use SetStore
would cause you to create a Works document that was not backed by the user store and which could eventually result in out-of-memory errors when the user added sufficient data to the document.SetStore
in the viewSetupFormScript
and AdoptEntryFromStationery
, or the intial text specified in the 2nd paramater to Replace
. (Notably, you may wish to provide styles for the text, see the Newton 2.1 OS documentation on the protoTXView
method Replace
.) // create and populate a dummy protoTXView
local textView := BuildContext(
{
_proto: protoTXView,
viewBounds: SetBounds(0, 0, 0, 0),
viewFlags: 0,
ReorientToScreen: ROM_DefRotateFunc,
viewSetupFormScript: func() begin
inherited:?viewSetupFormScript();
self:SetStore(GetDefaultStore());
end,
});
textView:Open();
textView:Replace({first: 0, last: 0}, {text: "Some initial text"}, nil);
// get the data in an external form for the Works soup
local saveData := textView:Externalize();
textView:Close();
// Create a new Works document from the data
GetRoot().NewtWorks:AdoptEntryFromStationery(
{
title: "Initial Title",
saveData: saveData,
hiliteRange: {first: 0, last: 0},
margins: {top: 72, left: 72, right: 72, bottom: 72},
}, 'paper, GetDefaultStore());
UnRegStamps
method, my registered stamps do not get unregistered. What is going wrong?UnRegStamps
method that causes stamps to remain registered. Use the following code to unregister your stamps:local viewDef := GetViewDefs( 'drawPaper ).default;
if viewDef then
begin
// Call UnregStamps conditionally. If the Draw application is not
// installed, GetViewDefs will return the "Missing Stationery"
// stationery.
viewDef:?UnregStamps( kStampRegistrySymbol );
local registry := GetViewDefs( 'drawPaper ).StampListRegistry;
if registry AND HasSlot( registry, kStampRegistrySymbol ) then
RemoveSlot( registry, kStampRegistrySymbol );
end;
UnRegStamps
method is required for future compatibility.