Chapter 5: Text
5.14. Review of Chapter 5: Text

1. In phrases or text to say, text in square brackets will be treated as a substitution. The thing to be said might be the name of an object:

say "[a dog]".

Text in square brackets might also be a property:

The printed name of a lamp is usually "[brightness] lamp".
The initial appearance of a person is usually "You notice [the item described]".

Here "the item described" refers to whatever object possesses the property in question.

2. Numbers and times of day may also be printed, and some special rules apply: we are allowed to tell Inform to say them "in words".

say "[The carpet area of the room]"
say "[The number of things carried by the player]"
say "[The number of things carried by the player in words]"
say "[The expiration time of the bus ticket]"
say "[The expiration time of the bus ticket in words]"

Times may also be rounded off:

say "[The expiration time of the bus ticket to the nearest 20 minutes]"
say "[The expiration time of the bus ticket to the nearest 20 minutes in words]"

See the chapter on Time for more discussion on representing and calculating times.

3. A text substitution may also be a list of things:

say "[the list of royal servants]"
say "[a list of containers which contain something]"
say "[list of fish without gills]"

"[list...]" and "[a list...]" have the same effect, namely to produce a list prefaced with indefinite articles ("a ham, a cabbage, Mr Darcy, some shoelaces..."), while "[the list...]" produces a list prefaced with definite articles ("the ham, the cabbage, Mr Darcy, the shoelaces..."). As we saw in an earlier chapter, lists will be punctuated with the serial comma if we have chosen the appropriate use mode, so a source text which contains the sentence:

Use the serial comma.

will result in all lists being of the form "Julian, Dick, George, and Anne" rather than "Julian, Dick, George and Anne".

4. We may also use bracketed commands to change the style of text or create breaks in the text layout:

say "[italic type]";
say "[roman type]";
say "[bold type]";
say "[line break]";
say "[paragraph break]";
say "[conditional paragraph break]";
say "[run paragraph on]".

Moreover, the following special bracketed forms exist to print characters that are otherwise hard to express:

say "[bracket]"
say "[close bracket]"

As we saw in an earlier chapter, the following are occasionally useful when Inform would otherwise make the wrong assumption about whether we want a single or a double quote mark:

say "[apostrophe]"
say "[quotation mark]"

5. We may enclose conditions in brackets:

The initial appearance of a person is "[The item described] stands here [if the item described is angry]glowering at you[otherwise]looking bored[end if]."

Note that we may use [if...], [otherwise], and [end if] in brackets, but it is not safe to nest if conditions. Because one set of [if...][end if] is within another set, the following will not work as we might wish:

The description of the chest of drawers is "A handsome set of cherry-wood drawers[if the top drawer is open] with the top drawer open[if the top drawer contains something] and its contents spilling out[end if][end if]."

6. In the event that we need a more complicated say instruction than we can express with a single if/otherwise/else set, we may require a specially-defined text substitution:

To say the drawer-state:
    say "A handsome set of cherry-wood drawers";
    if the top drawer is open:
        say " with the top drawer open";
        if the top drawer contains something:
            say " and its contents spilling out";
    say "."

This creates the new text substitution "[the drawer-state]". The definition is an example of creating what's called a "phrase" in Inform. Phrases will be the subject of a whole chapter later on, but for now the point to keep in mind is that a phrase whose definition begins with the word "say" creates a new text substitution.

7. The most common European accented letters can be typed directly anywhere in the source text, but more obscure ones can only appear inside quoted text. If we want to avoid typing these directly, we can describe them with the special substitution [unicode ...], where we either give the Unicode number (in decimal) or its (Unicode standard) name. Names can only be used if we have included the extension Unicode Character Names by Graham Nelson; for really obscure names, we need Unicode Full Character Names by Graham Nelson, though having to read this very large extension will slow Inform down.

8. As a special effect, we can create quotations that float in a box near the top of the screen. The way to do this is

display the boxed quotation "Last night I dreamt I went to Manderley again.";

Text substitutions may not appear in boxed quotations (any square brackets will come out as literal square brackets). The "display the boxed quotation" instruction may be given as part of a rule or phrase, such as "After eating the tainted lobster", and will actually appear to the player just before the next command prompt after the quotation is prepared; a boxed quotation that has been displayed once will not be repeated.

If we want to do more exotic effects along these lines, there are extensions that allow more complicated manipulation of the screen.


PreviousContentsNext