Additional NewtonScript Features

Operators

NewtonScript provides the standard arithmetic operators +, -, *, and /, as well as integer divide (div) and integer remainder (mod). These and the rest of the NewtonScript operators are described in TABLE 3.1.

NewtonScript operators grouped in precedence order.
OperatorOperationAssociativity
(if not left-to-right)
Example
.slot access myFrame.slot
:message send aView:Open()
:?conditional message send aView:?GetSize()
[]array dereference myArray[5]
-negate -6
>>right-shift 8 >> 2
<<left-shift 3 << 1
*multiply 5 * 6
/real division 10 / 3.5
divinteger division 17735 div 6
modinteger remainder 17735 mod 6
+add 8 + 10
-subtract 9.5 - 6.3
&concatenate string representations "6*3 = " & 6*3
&&same as &, but with a space "6*3:" && 6*3
existsvariable and slot existencenoneaFrame.foo exists
<less than 5 < 10.3
<=less than or equal to 5 <= 10.3
>greater than 5 > 10.3
>=greater than or equal to 5 >= 10.3
=equal to a = b
<>not equal to a <> b
notboolean not not a < 3
andboolean and (short-circuit) x and x.y <= 6
orboolean or (short-circuit) a > 2 or b < 6
:=assignmentright-to-lefta := b


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

Last modified: 1 DEC 1996