I was going through section 16.3 of “Writing with Inform” and based on that I did this:
The Learning Lab is a room.
Table 2.1 - Selected Elements
Element Symbol Atomic Number Atomic Weight
"Hydrogen" "H" 1 1
"Iron" "Fe" 26 56
"Zinc" "Zn" 30 65
"Uranium" "U" 92 238
When play begins:
if there is an element corresponding to an atomic number of 27 in the Table of Standard Elements:
say "Atomic number 27 is in the table.";
if there is an atomic number of 27 in the Table of Standard Elements:
say "Atomic number 27 is in the table.";
My understanding from the manual is that this should protect me from run-time errors, in the sense of referring to non-existent rows. However, this doesn’t even compile. It says:
But then it turns out this error happens if I use an atomic number that does exist in the table. For example, change 27 in my code above to 26. That should match “Iron”. I thought maybe it had to do with the fact that I’m referencing a number, so I tried a modification like this:
if there is an element corresponding to a symbol of "Fe" in the Table of Standard Elements:
Here just replacing atomic number and a numeric value with symbol and a string value. Same error, however, upon compile.
This happens with both variations on the conditional. That’s why I have both in place. I would comment out the first one to see if the second one worked.
You are also completely fine with saying “Hey, idiot! Proofread your code!” Particularly when I do something that dumb.
Side story: it’s funny because I’ve taken a break from Inform related things and I’ve been using a variety of other languages. One thing that slips a bit, I found, when you move between a lot of languages is some of the most common sense diagnostic aspects. Anyway – thanks for the assist.
Ha ha, I’d never snark on someone for that sort of thing–can’t count how much time I’ve spent trying to figure out some tricky syntax I thought I’d mangled when the problem was that I’d misspelled the word “tchotchkes” or something like that. What do you mean, you don’t understand what the subsituted form is?
ETA: One of the tricky things is that Inform knows that “If there is a…” is something you use only when looking up table entries. If you typed “When play begins: If there is a boing, do nothing.” you’d get the same “value, not a reference to a table” error. This makes it seem like Inform understood more of what you meant than it actually did.