do While loops no longer exist in I7?

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.

“While” loops are kind of like “repeat” loops in that they don’t automatically trigger–you need to tell Inform when to execute them. This will usually be a rule for an action, or an every turn rule:

Every turn: while a person (called the victim) is in the Crypt: say "A bolt of lightning strikes [the victim]!"; now the victim is in the Afterlife;

Do this, and every person who is in the Crypt will be struck by lightning every turn.

Or you could give it a more specific trigger:

[code]The Chamber is a room.

The Crypt is east of The Chamber.

The Afterlife is a room.

Bob, Alex, and Charlie are men in the Crypt.

The obviously cursed goblet is in the Crypt.

After taking the obviously cursed goblet:
while a person (called the victim) is in the Crypt:
say “A bolt of lightning strikes [the victim]!”;
now the victim is in the Afterlife;[/code]

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).

1 Like

Making a statement like that implies you have read the entirety of the built-in documentation “cover to cover”, yes?

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.)

Another question for neroden: Have you compiled a game and then gone through the index? That pretty much breaks down every phrase, verb, action, object, rule, etc., in use in the game.