http://www.newton-inc.com/dev/techinfo/qa/qa.htm
AfterScript
to set the appropriate slot in the view to point to the ROM based PICT (assuming that the constant for the PICT is defined in the NTK definitions file AND documented in the Newton Programmers Guide). Use something like this in the AfterScript
:
thisView.icon := ROM_RouteDeleteIcon;
protoStaticText
text slot that is in one linked layout window from a button that is in another linked layout window. I tried to allow access to the base view from both linked layouts, but this didn't help. I even tried to allow access from the base view to both layouts, but this didn't help, either. What should I do?textThatChanges
which a child of a view called changingContainer
and is declared to changingContainer
with the name textThatChanges
. ChangingContainer
is the base view for a layout which is linked into the main layout, and the link (in the main layout) is declared as changingContainerLink
. Code in the main layout can change the text of the textThatChange
view like so: SetValue(containerLink.whatToDo, 'text, "Turn and face the...")
viewSetupFormScript
script of the 'buttonThatChanges
button, set the value of the base view's slot 'theTextView
to self
, as in the following code fragment: func()
begin
base.theTextView := self;
end
2) In the buttonClickScript
script of the 'buttonThatSetsText
button, use the global function SetValue
to store new text in the text slot of the 'buttonThatChanges
button, as in the following code fragment: func()
begin
SetValue(base.theTextView, 'text, "Now something happened!");
end
Note that this example assumes the self-declared view called base
. In your application, you may access your base view in a different way.StrCompare
can return different results at compile time than it does at run time. What gives?StrCompare
on an given Newton unit. Here is one such function for English releases of the Newton OS (which assumes strings using only page 0 of the unicode table):constant kNSortTable := '[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24, 25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46, 47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68, 69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90, 91,92,93,94,95,96,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80, 81,82,83,84,85,86,87,88,89,90,97,98,99,100,101,102,103,104,105,106, 107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122, 123,124,125,126,127,128,129,130,131,132,133,161,157,135,136,165, 149,138,137,143,141,152,159,158,144,140,170,134,146,147,148,142, 150,138,168,171,151,153,160,153,154,155,156,174,174,174,174,65, 65,145,67,175,69,175,175,176,176,176,176,162,78,177,177,177,79, 79,164,79,178,178,178,85,166,167,139,65,65,65,65,65,65,145,67,69, 69,69,69,73,73,73,73,169,78,79,79,79,79,79,163,79,85,85,85,85,172, 173,89];
// function to compare strings (only page 0 characters)
// with the same order as the Newton ROM does.
DefConst('kNewtonStrCompare, func(s1, s2)
begin
local l1 := StrLen(s1);
local l2 := StrLen(s2);
local l := Min(l1, l2);
local i := 0;
while i < l and
(r := kNSortTable[ord(s1[i])] - kNSortTable[ord(s2[i])]) = 0 do
i := i + 1;
if i = l then
l1-l2
else
r;
end);
Note that just because you might find a particular function to be defined at compile time, do not assume that it behaves in exactly the same way as the like-named run-time function, unless the documentation explicitly says it does. (And, of course, it might not always be defined in the compile-time environment of future NTK products if it isn't documented that way.) call func(theFrame) begin
local i := 0;
foreach slot, value in theFrame do begin
print(i && ': && slot);
i := i + 1;
end
end with (<the reordered frame>)
Main Build time
heap size (+/- 0.5 sec)
1250K Main heap ran out of memory...
1275K 32.7 sec
1300K 26.4 sec
1400K 22.3 sec
1500K 19.2 sec
1600K 17.5 sec
2000K 16.0 sec
3000K 15.2 sec
GlobalData
file (in the NTK folder) and restart NTK: protoEditor:DefineKey({key: 65}, 'EvaluateSelection);
This allows you to use the period key on the numeric keypad to evaluate selected text in the Inspector window or any text file in the NTK build-time environment. (Normally the text is compiled by NTK and then evaluated by the Newton device when you hit the Enter key.) See the NTK User's Guide for details on the GlobalData
file.VerboseGC(TRUE)
in the Inspector window, select, and hit the keypad-period key. Each time the GC kicks in, a line will be displayed in the Inspector window. By watching the frequency of GCs, you can get some idea of how your main heap is being used.VerboseGC(FALSE)
to turn this feature off. Please note that VerboseGC
is available only in the NTK build-time environment. The function does not exist on the Newton device itself. It should be used only for debugging and optimization. if x = 1 then
dosomething
else
if x = 2 then
doSomethingElse
else
if x = 3 then
doYetAnotherThing
else
if x = 4 then
doOneMoreThing
else
if x = 5 then
doSomethingSimple
else
if x = 6 then
doThatThing
else
if x = 7 then
doThisThing
else // x = 8
doTheOtherThing
...can be rewritten like this: if x <= 4 then
if x <= 2 then
if x = 1 then
doSomething
else // x = 2
doSomethingElse
else
if x = 3 then
doYetAnotherThing
else // x = 4
doOneMoreThing
else
if x <= 6 then
if x = 5 then
doSomethingSimple
else // x = 6
doThatThing
else
if x = 7 then
doThisThing
else // x = 8
doTheOtherThing;
Note that the if/then/else statement nesting is "unusual" to illustrate the nesting that the compiler must make each statement is nested as the compiler would process it.
if x = 1 then
dosuchandsuch;
else
if x = 2 then
dosomethingelse;
else
if x = 3 then
andsoon;
...can be rewritten like this: cmdArray := [func() dosuchandsuch,
func() dosomethingelse,
func() andsoon];
call cmdArray[x] with ();
if x = 'foo then
dosuchandsuch;
else
if x = 'bar then
dosomethingelse;
else
if x = 'baz then
andsoon;
cmdFrame := {foo: func() dosuchandsuch,
bar: func() dosomethingelse,
baz: func() andsoon};
call cmdFrame.(x) with ();
Increase NTK's stack size using the ResEdit applicationmem!
" resource icon1000
named "Additional NTK Memory Requirements"0001 8000
" which is 98304
bytes (or 96k
) to add to the total stack size. For example, to increase this value to 128k
= 131072
bytes change the hexadecimal value to "0002 0000
".DeclareUnit
, before it's used (imported or exported.) See the docs on DeclareUnit
below for details.DefineUnit
and specify the NS objects that are exported.UnitReference
(or UR for short.)DeclareUnit(unitName, majorVersion, minorVersion, memberIndexes)
unitName
- symbol - name of the unitmajorVersion
- integer - major version number of the unitminorVersion
- integer - minor version number of the unitmemberIndexes
- frame - unit member name/index pairs (slot/value)
A unit must be declared by DeclareUnit
before it's used (imported or exported.) The declaration maps the member names to their indexes. A typical declaration looks like: DeclareUnit('|FastFourierTransforms:MathMagiks|, 1, 0, {
ProtoGraph: 0,
ProtoDataSet: 1,
});
.h
files in C.)
DefineUnit(unitName, members)
unitName
- symbol - name of the unitmembers
- frame - unit member name/value pairs (slot/value) DefineUnit
exports a unit and specifies the value of each member. Immediates and symbols are not allowed as member values. A typical definition looks like: DefineUnit('|FastFourierTransforms:MathMagiks|, {
ProtoGraph: GetLayout("foo.layout"),
ProtoDataSet: { ... },
});
n
members must contain n
slots with indexes 0..n-1
. The definition must specify a value for every declared member (this is important.)UnitReference(unitName, memberName)
orUR(unitName, memberName)
unitName
- symbol - name of a unitmemberName
- symbol - name of a member of unitUnitReference
(UR
for short) with the unit and member name.'ROM
can be used to refer to obects in the base ROM. For example:UR('ROM, 'ProtoLabelInputLine)
.ProtoLabelInputLine
or ROM_SystemSoupName
.UR
, the unitName, and the memberName. This is the mechanism by which licensees can provide product-specific functionality.
AliasUnit(alias, unitName)
alias
- symbol - alternate name for unitunitName
- symbol - name of a unit AliasUnit
provides a way to specify an alternate name for a unit. Since unit names must be unique, they tend to be long and cumbersome. For example: AliasUnit('FFT, '|FastFourierTransforms:MathMagiks|);
local data := UR('FFT, 'ProtoDataSet):New(points);
local data := UR('|FastFourierTransforms:MathMagiks|,
'ProtoDataSet):New(points);
AliasUnitSubset(alias, unitName, memberNames)
alias
- symbol - alternate name for unitunitName
- symbol - name of a unitmemberNames
- array of symbols - list of unit member names AliasUnitSubset
is similar to AliasUnit
, except that it additionally specifies a subset of the units members which can be used. This helps restrict code to using only certain members of a unit.
RemovalApproval(unitName, majorVersion, minorVersion)
unitName
- symbol - name of the unitmajorVersion
- integer - major version number of the unitminorVersion
- integer - minor version number of the unitnil
or string"This operation will cause your connection to fooWorld to be dropped."
ImportDisabled
message (see below) will be sent. RemovalApproval
can return nil
and the user will not be bothered.
ImportDisabled(unitName, majorVersion, minorVersion)
unitName
- symbol - name of the unitmajorVersion
- integer - major version number of the unitminorVersion
- integer - minor version number of the unitMissingImports(pkgRef)
return value - nil
or an array of frames (see below)kMissingImportsFunc
MissingImports
lists the units used by the specified package that are not currently available. MissingImports
returns either nil, indicating there are no missing units, or an an array of frames of the form: {
name: symbol - name of unit desired
major: integer - major version number
minor: integer - minor version number
<other slots undocumented>
}
mySoup:Query({words: "pizza"}
) don't sucessfully find the entries. Why?SetClass(SetLength("\u<hex data>"), theLength), theClass)
in Windows NTK , the binary object is not what I expect. It seems to be byte-swapped. How can I create binary objects with data in them in Windows NTK?MakeBinaryFromHex()
function; it handles the byte-swapping issues properly. This function is defined by the platform file, and only runs at build-time -- it doesn't exist on the Newton device. You may need to get a newer platform file because this function was added after Windows NTK 1.6 shipped.