That piece of code is not working for me in inform 7, why?
List of Problems:
Problem. You wrote 'else if i is 2' : but this seems to say that a thing is a value, like saying 'the chair is 10'.
Problem. You wrote 'let c be character number one in a' : but I can't find a verb here that I know how to deal with, so I am ignoring this sentence altogether.
See the manual: 2.17 > Review of Chapter 2: The Source Text
Problem. You wrote 'let d be character number one in b' : again, I can't find a verb here that I know how to deal with.
Problem. You wrote 'if c matches the regular expression "<^A-Z>", say "That spell has no obvious effect." instead' : but I can't find a verb that I know how to deal with. This looks like an 'if' phrase which has slipped its moorings, so I am ignoring it. ('If' phrases, like all other such instructions, belong inside definitions of rules or phrases - not as sentences which have no context. Maybe a full stop was accidentally used instead of semicolon, so that you inadvertently ended the last rule early?)
See the manual: 11.6 > If
Problem. You wrote 'if d matches the regular expression "<^A-Z>", say "That spell has no obvious effect."' : again, I can't find a verb that I know how to deal with. This looks like an 'if' phrase which has slipped its moorings.
Problem. You wrote 'let e be the encryption of a' : again, I can't find a verb here that I know how to deal with.
Problem. You wrote 'let f be the encryption of b' : again, I can't find a verb here that I know how to deal with.
Problem. I am reading the sentence 'if e is b, skip to the endgame instead' as a declaration of the initial state of the world, so I'm expecting that it will be definite. The only way I can construe it that way is by thinking that 'if e' and 'b' are two different things, but that doesn't make sense, and the 'if' makes me think that perhaps you did not mean this as a definite statement after all. Although 'if...' is often used in rules and definitions of what to do in given circumstances, it shouldn't be used in a direct assertion.
Problem. You wrote 'if f is a, skip to the endgame instead' : but this seems to give something a name which consists only of an article, that is, 'a', 'an', 'the' or 'some'. This is not allowed since the potential for confusion is too high. (If you need, say, a room which the player sees as just 'A', you can get this effect with: 'A-Room is a room with printed name "A".')
Problem. You wrote 'say "That spell has no obvious effect."' : again, I can't find a verb here that I know how to deal with.
Problem. You wrote 'else' : again, I can't find a verb here that I know how to deal with.
Problem. You wrote 'say "That spell has no obvious effect."' : again, I can't find a verb here that I know how to deal with.
Problem. You wrote 'end if' : again, I can't find a verb here that I know how to deal with.
Problem. You wrote 'Incanting is an action applying to one topic' : but that seems to be an action already existing, so it cannot be redefined now. If you would like to reconfigure an action in the standard set - for instance if you prefer 'unlocking' to apply to only one thing, not two - create a new action for what you need ('keyless unlocking', perhaps) and then change the grammar to use the new action rather than the old ('Understand "unlock [something]" as keyless unlocking.').
See the manual: 12.7 > New actions