
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.
Operator | Operation | Associativity (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 |
div | integer division | | 17735 div 6 |
mod | integer 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 |
exists | variable and slot existence | none | aFrame.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 |
not | boolean not | | not a < 3 |
and | boolean and (short-circuit) | | x and x.y <= 6 |
or | boolean or (short-circuit) | | a > 2 or b < 6 |
:= | assignment | right-to-left | a := 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