// previous page's name
$previous = 'boolean';
// page's name
$current = 'conditions';
// next page's name
$next = 'loops';
// print top of page
In programming, a condition is something that must be true in order for something to happen. A condition is thus said to "evaluate to true" or "evaluate to false." In Scratch, any block whose label says "if," "when," or "until" is a sort of conditional construct.
One such block is:
The construct above is generally known as an "if construct." With it can we instruct a sprite to say hello only if, say, the user has depressed the mouse button:
A related construct is the "if-else construct":
With the above construct can we instruct a sprite to say hello or goodbye, depending on whether the user has depressed the mouse button:
Realize that these constructs can be nested to allow, for example, for three different conditions:
The above construct could be called an "if-else if-else construct".
Another conditional block is:
Yet another such block is:
Sometimes, you want one or more statements to be executed multiple times in a row. To implement this behavior, we turn our attention to loops.
// print bottom of page