[I7] comparing entries from tables

Hello,

I can’t compare a table entry with a number.

Here is my table:

Table of Recollections Topic Response Mark (a number) "Farvardin" "Tell something about farvardin..." 0

When the player remember something, I change the “Mark” number like this:

Instead of remembering a topic listed in the Table of Recollections: say "[response entry][paragraph break]"; change mark entry to 1;

During the game, I’d like to be able to test if the player tried to remember a particular topic:

Every turn: if the Mark number corresponding to a topic of "Farvardin" in the Table of Recollections is greater than 0 begin; ... do something ...; end if;

and all I get is:

Should it be “mark corresponding to” instead of “mark number corresponding to”?

thank you, you are right. I was misleaded by the example in chapter 15.3: “the atomic number corresponding to a symbol of “Fe” in the Table of Selected Elements”

The table row was called “atomic number”, not just “atomic”, so we musn’t say it’s a number.

Anyway, using a similar construct, it doesn’t completely work:

	if the Mark corresponding to a topic of "Farvardin" in the Table of Recollections is greater than 0

I get an error during run-time: *** Run-time problem P21: Attempt to look up a non-existent correspondence in the table ‘Table of Recollections’.

and even if the Mark is equal to 0, it displays what it shouldn’t.

I’ve found a workaround:

if the Mark in row 1 of the Table of Recollections is greater than 0

I musn’t change the rows later, but at least it works as expected. Thank you again.

Hmm. Poking around a little, my guess is that you’re not actually allowed to compare a topic with a text that you type directly into the source code like that – topics are for comparing to the player’s command only. It seems like there ought to be some way to make this work as a topic, but alas. (One of the difficulties is that topics could be like “Farvardin/Favardin” or “[any person]”, which makes direct comparison more complicated.)

One workaround, which would let you rearrange the rows later if you want, might be to set up another columns with text entries and compare your string to that instead. So you could have a column called “real name”, with “Farvardin” in it again, and then test the Mark corresponding to a real name of “Farvardin”.

well, you’re right again. The syntax above works if I use a new column, for example RealName (" if the Mark corresponding to a RealName of “Farvardin” in the Table of Recollections is greater than 0")

So it was just a variable/name clash. I thought (wrongly) that Inform could manipulate the Topic like other things. Thank you for the help.

Well, I don’t think it’s exactly a variable/name clash. In general quoted strings in the source code are interpreted as text, you call a column “topic” the text strings in it are interpreted as a very special kind, topic (which can be compared with the player’s command). So “Farvardin” in the topic column is interpreted as a topic, and “Farvardin” in the RealName column and the other time you wrote it is interpreted as a text. And apparently texts and topics don’t play nicely together.

Anyway, glad I could help.