| Chapter 11: Phrases |

| 11.12. Phrase options

There are often several slightly different ways to perform a given task but which have substantially the same definition. In the following example:

> To go hiking, into the woods or up the mountain:
> if into the woods then say "Watch out for badgers.";
> if up the mountain then say "Better take your compass.";
> say "You go hiking."

...a phrase has been set up which can be used in three ways:

> go hiking;
> go hiking, into the woods;
> go hiking, up the mountain;

Note that commas must be used to divide these "phrase options" from the rest of the text of the phrase. Within the definition of the phrase, the option's name is a valid condition, and

> if up the mountain then ...

is true if the phrase was called with "up the mountain" specified and false otherwise, in the obvious way. A more substantial example from the standard rules is given by the Inform list-writer, which produces lists of things to specifications we choose. For instance:

> list the contents of Marley Wood, as a sentence, with newlines
> and including all contents;

Note that this phrase is allowed to have multiple options specified, whereas "go hiking" above was not: this is because it was defined thus:

> To list the contents of (something - an object), with newlines, indented, as a sentence, including contents, including all contents, giving inventory information, giving brief inventory information, using the definite article, listing marked items only, prefacing with is/are, not listing concealed items, suppressing all articles and/or with extra indentation: ...

The significant difference is the word "and/or" instead of "or", which signals that more than one option can apply at a time.

(As it happens, not all of the above options are equally useful: "not listing concealed items", for instance, is probably helpful only to people creating projects which mingle Inform 6 and Inform 7 material. "Concealed" is a concept no longer in use.)

144
| Example Equipment List Overview of all the phrase options associated with listing, and examples of how to change the inventory list into some other standard formats.

Previous | Contents | Next