Apple Shake 4 User Manual

Page 960

Advertising
background image

960

Chapter 31

Expressions and Scripting

In the interface, you can also use the Select node to switch between any number of
input nodes. (For more information on the Select node, see “

Select

” on page 471.) This

strategy allows you to stay within the interface without resorting to the script.
However, the difference is that Shake only builds the part of the script that it needs for
conditional statements listed below. Select has the overhead of all of its input nodes.

Finally, ++i or --i is supported for increments. i++ is as well, but returns a warning
message.

If/Else
This is used to express decisions. If the test expression is true, then the first statement is
executed. If false (and an “else” part exists), then the second statement is executed. If
“else” is left off, Shake does nothing and moves on.

if (expression evaluates to non-zero) {

do_this

} else if {

do_this

} else if {

do_this

} else {

do_this

}

or just

if (expression evaluates to non-zero) {

do_this

} else if {

do_this

}

For
Normally, the three expressions of the “for” loop are an initialization (a=1), a relational
test (a<10), and an increment (a++): for (a=1; a<10; a++). So “a” is set to one, checked if
it is less than 10, then if that is true, a statement performed, and “a” is incremented by
one. The test is checked again and this cycle continues until “a” is found to be not less
than 10 (untrue).

for (initialize; test; increment)
{

do_this

}

While
If the given expression is true or non-zero, the following statements are performed, and
the expression is reevaluated. The cycle continues until the expression becomes false.

while (this_expression_is_true)
{

do_this

}

Advertising