Inform 7 Home Page / Documentation


Chapter 20: Advanced Text

§20.1. Changing texts; §20.2. Memory limitations; §20.3. Characters, words, punctuated words, unpunctuated words, lines, paragraphs; §20.4. Upper and lower case letters; §20.5. Matching and exactly matching; §20.6. Regular expression matching; §20.7. Making new text with text substitutions; §20.8. Replacements; §20.9. Summary of regular expression notation

arrow-up-left.png Contents of Writing with Inform
arrow-left.png Chapter 19: Rulebooks
arrow-right.png Chapter 21: Lists
arrow-down-right.png Indexes of the examples

§20.1. Changing texts

So far, we have dealt with text as something which comes in little packets: we have printed it out, read it in from the keyboard, and compared it with other text. But we have never tried to open the packets and get at the contents, letter by letter, or to make any alterations, or look for certain combinations of letters. These tricks are surprisingly seldom needed - a surprise, that is, given that everything Inform does is textual - but they are in fact open to us. For example:

if character number 1 in "[time of day]" is "1", ...

will be true at, for example, 11:30 PM and 1:22 AM, but not at 3:15 PM. What happens here is that Inform expands the time of day into a text, say "11:30 PM", then extracts the first character, say "1", and tests it.

Until 2012, Inform had two kinds of text - plain "text", and "indexed text" - but there's now only "text", which has all of the abilities of both.


arrow-up.png Start of Chapter 20: Advanced Text
arrow-left.png Back to Chapter 19: Rulebooks: §19.16. The Laws for Sorting Rulebooks
arrow-right.png Onward to §20.2. Memory limitations