| Chapter 11: Phrases |

| 11.7. Begin and end

In practice it is not enough to apply "if" or "while" to a single phrase alone: we want to give a whole list of phrases to be followed repeatedly, or to be followed only if a condition holds.

We do this using "begin" and "end", as in the following examples.

> To comment upon (whatever - a thing):
> if whatever is transparent then say "I see right through this!";
> if whatever is an open door begin;
> say "Oh look, an open door!";
> if whatever is openable then say "But you could always shut it.";
> end if.

Here we group two phrases together under the same "if". Note that the "then" has been replaced by "begin", and that the end is marked by "end if".

Similarly for while:

> while (condition) begin; (... phrases ...); end while

The "begin" of an "if" must of course match an "end if", not an "end while", and so on.

138
| Example Matreshka A SEARCH [room] action that will open every container the player can see, stopping only when there don't remain any that are closed, unlocked, and openable.

139
| Example Princess and the Pea The player is unable to sleep on a mattress (or stack of mattresses) because the bottom one has something uncomfortable under it.

Previous | Contents | Next