Inform 7 Home Page / Documentation


§16.19. Table amendments

Tables can have amendments as well as continuations. The arrangement is much the same: a supplementary table supplies new rows for the original table. But instead of adding the new rows at the end of the original, as a continuation would, an amendment replaces matching rows in the original. (So the original stays the same size.)

The amendment table must have exactly the columns of the original and in the same order. Moreover, each row in the amended table must match exactly one row in the original. For instance:

Table of Plans

moment

outcome

10 AM

"takeover of Mars"

11:30 AM

"canals reflooded"

11:45 AM

"chocolate bar production doubled"

Table of Plans (amended)

moment

outcome

11:45 AM

"volcanic cave production doubled"

creates a three-row Table of Plans, with reference to the chocolate bars struck out.

Amendment rows may be given in any order. The process of matching a row begins at the left-most column: Inform tries to see if any single row in the original table has a matching entry. If none does, a Problem is issued. If more than one do, Inform then looks at the second column, and so on. For instance:

Enthusiasm is a kind of value. The enthusiasms are pumped, wired and languid.

Table of Mental States

feeling

extent

consequence

pumped

1

"you feel able to run for your life"

pumped

2

"you feel able to run for President"

wired

1

"you feel able to run"

languid

1

"you feel"

Table of Mental States (amended)

feeling

extent

consequence

pumped

2

"you feel able to run for the Nebraska State Legislature"

Here the amendment is made to the second row of the original table. The value in the leftmost column, "pumped", matches two rows in the original, so Inform moves on to the next column, reads "2", and finds that only one row in the original still qualifies - so that is the one replaced.

For the present, at least, the columns used for matching may only contain: numbers, times, objects, action names, activities, figure names, sound names, truth states and any new kinds of value or units which have been declared.


arrow-up.png Start of Chapter 16: Tables
arrow-left.png Back to §16.18. Table continuations
arrow-right.png Onward to Chapter 17: Understanding: §17.1. Understand

**ExampleTrieste
Table amendment to adjust HELP commands provided for the player.