Additional NewtonScript Features
if expression then statement
if expression then statement1 else statement2
if
statements are similar to those found in other languages. Here are some examples:
if a < b then min := a else min := b; if a < b then x := y; min := if a < b then a else b;An
if
statement has a value--like all NewtonScript statements. Where an else
is lacking, the value of the if
statement is either:
if, or
nil
else
, then the value of the if
statement is either:
if
, or
else
.
else
, it is associated with the closest preceding if
. For instance,
if a < b then if b < c then x := y else y := x;is parsed as
if a < b then if b < c then x := y else y := xrather than as
if a < b then if b < c then x := y elseThere is one other important point abouty := x
if
statements:
else
.
An online version of Programming for the Newton using Macintosh, 2nd ed. ©1996, 1994, Julie McKeehan and Neil Rhodes.
Last modified: 1 DEC 1996