So I was trying to teach myself loops (with the ultimate goal of creating a multiple choice question that repeats itself until the player gets the right answer) and tried creating this basic code based off “11.9 While” in the documentation. When I tried to compile though, the compiler didn’t recognize my While phrase, so I wanted to know what I typed wrong, or if I7 doesn’t recognize while loops.
The Chamber is a room.
The Crypt is east of The Chamber.
While someone (called the victim) is in the Crypt:
say "A bolt of lightning strikes [the victim]!"
now the victim is in the Afterlife;
The Afterlife is a room.
I tried adding an “end while” statement to close the loop, but the compiler didn’t recognize that, either.
A more accurate and general statement is that you were trying to write procedural code in a declarative context.
The top level of an Inform 7 file is purely declarative. All declarations. Like a Makefile or a Prolog file. Procedural code must ONLY be inside one of those declarations (specifically, procedural code must only be inside a phrase or rule declaration).
The completely appalling state of the Inform 7 documentation obscures this utterly basic fact. I’ve been starting in on writing a High Level Overview of Inform 7 to remedy this, but I’m having a little trouble with the tone because I keep insulting the writers of Writing With Inform, which is probably unnecessary (though arguably deserved).
I have my beefs with the Inform documentation, but it does seem as though this particular issue is addressed in the first two sections that deal with the language (Chapter 1 is about the IDE). §2.1:
If I understand the terms you’re using correctly, the assertions are declarative code, and the rules are declarative code with procedural code inside it. But putting it that way wouldn’t be awfully helpful to non-programmers (me, for instance), who don’t deal with Makefiles and Prolog files. It was much more helpful for me to see that there were some assertions that set the initial conditions, and other rules that specified the rules of play.
Since you’re clearly coming at Inform from a more programmery perspective, have you seen Ron Newcomb’s Inform 7 Programmer’s Manual? It seems like it might be up your alley. It’s directed at version 6G60 of Inform 7 rather than the latest version, but if you start with that it shouldn’t be hard to adapt to the changes in the latest version. (Anyway, I see from your extension that you’ve been working with Original Parser, so you must be doing some 6G60 stuff.)