5.2. How Inform reads quoted text

| Chapter 5: Text |

| 5.2. How Inform reads quoted text

Text is so fundamental to Inform that the basics had to be covered back in Chapter 2, so let's begin this new chapter with a recap.

Literal text is written in double-quotation marks. It's mostly true that what you see is what you get: the literal text "The Hands of the Silversmith" means just

> The Hands of the Silversmith

But four characters are read in unexpected ways: [, ], ' and ". The rules are as follows:

Exception 1. Square brackets [ and ] are used to describe what Inform should say, but in a non-literal way. For example,

> "Your watch reads [time of day]."

might produce

> Your watch reads 9:02 AM.

These are called "text substitutions". They're highly flexible, and they can take many different forms. But as useful as they are, they do seem to stop us from making actual [ and ] characters come through on screen. To get around that:

say "[bracket]"

This text substitution expands to a single open square bracket, avoiding the problem that a literal [ in text would look to Inform like the opening of a substitution. Example: "He [bracket]Lord Astor[close bracket] would, wouldn't he?" prints as "He [Lord Astor] would, wouldn't he?".

say "[close bracket]"

This text substitution expands to a single open square bracket, avoiding the problem that a literal ] in text would look to Inform like the closing of a substitution. Example: "He [bracket]Lord Astor[close bracket] would, wouldn't he?" prints as "He [Lord Astor] would, wouldn't he?".

Exception 2. Single quotation marks at the edges of words are printed as double. So:

> "Simon says, 'It's far too heavy to lift.'"

produces

> Simon says, "It's far too heavy to lift."

This is good because typing a double quotation mark inside the quote wouldn't work - it would end the text then and there. Single quotation marks inside words, such as the one in "it's", remain apostrophes.

The rule looks odd at first, but turns out to be very practical. The only problem arises if we need an apostrophe at the start or end of a word, or a double inside one. Again, substitutions can fix this:

say "[apostrophe/']"

This text substitution expands to a single quotation mark, avoiding Inform's ordinary rule of converting literal single quotation marks to double at the edges of words. Example: Instead of going outside, say "Lucy snaps, 'What's the matter? You don't trust my cookin[apostrophe] mister?'" produces: Lucy snaps, "What's the matter? You don't trust my cookin' mister?" A more abbreviated form would be: Instead of going outside, say "Lucy snaps, 'What's the matter? You don't trust my cookin['] mister?'" which has exactly the same meaning.

say "[quotation mark]"

This text substitution expands to a double quotation mark. Most of the time this is unnecessary because of Inform's rule of converting literal single quotation marks to double at the edges of words, so it's needed only if we want a double-quote in the middle of a word for some reason. Example: "The compass reads 41o21'23[quotation mark]E." which produces: The compass reads 41o21'23"E. (Note that ["] is not allowed; a double-quotation mark is never allowed inside double-quoted text, not even in a text substitution.)

Exception 3. Texts which end with sentence-ending punctuation - full stop, question mark, exclamation mark - are printed with a line break after them. So:

> say "i don't know how this ends";
> say "I know just how this ends!";

would come out quite differently - this doesn't affect the appearance of the text, but only the position where the next text will appear. Again, sometimes this is not what we want - the full rules are complicated enough to be worth a whole section later in the chapter.

Previous | Contents | Next