IF tabs do not seem to be aligning.

What is wrong with this:

Check Flashlight Status:
	if flashlight is switched from off to on:
		say "A friendly sounding old voice says Better turn that thing off to save it for later.";
	otherwise:
		say "Leaving it on is a good idea!".

IF tells me the tabs are not properly aligned. I am running under Windows XP on a Dell. My source is on a thumb drive.

If you paste example code into code or quote, I think it preserves your tabs. Or maybe you didn’t put any tabs in originally?

Also, you didn’t post any surrounding code, so I’m not sure how I7 deals with check rules that aren’t in rulebooks. (Is it in a rulebook?) You might want “To check flashlight status:” instead, if you didn’t.

If none of that helps, maybe post a short example that gives the error?

When I quote your message, I can see your tabs. The tabs are not mis-aligned (unless you have everything indented one tab too far, which is possible). But I’m seeing some other potential problems with this code. I’ve never seen a rule that checked whether the switching action was “from off to on.” I’m not sure you can do that. What you need here is two separate rules, one for the switching on action, the other for the switching off action.

Also, it’s not clear to me how you expect the flashlight ever to be switched on, if the voice suggests turning it off when you try to turn it on. I’d offer some sample code, but I really don’t know what you’re trying to do here.

I am almost ready to believe there is something strange going on. I tried the following and got:

To Test Flashlight:
	if the flashlight is on: 
		say "A friendly sounding old voice says Better turn that thing off to save it for later";
	otherwise:
		say "Leaving it on is a good idea!".

Problem. The phrase or rule definition ‘To Test Flashlight’ is written using the ‘colon and indentation’ syntax for its 'if’s, 'repeat’s and 'while’s, where blocks of phrases grouped together are indented one tab step inward from the ‘if …:’ or similar phrase to which they belong. But the tabs here seem to be misaligned, and I can’t determine the structure. The first phrase going awry in the definition seems to be ‘if the flashlight is on’ , in case that helps.

When you post these here, you need to wrap them in code tags, or your tabs will not be preserved. It’s impossible to tell from these last two posts whether the indentation is correct, or indeed whether there is any indentation at all.

–Erik

If you’re saying “How do I get code tags?” there’s a button for them above the box where you type your post. Hit the button, copy your code from the Inform development pane, and paste it in between the code tags, thus:

code goes here

The <> will show up as []. (If you like, you can also just type , replacing the angle brackets with square brackets.)

Here is a test game that should compile. Is this how you’re aligning your tabs?

[code]The Basement is a room.
The flashlight is a device in the basement.

To Test Flashlight:
if the flashlight is switched on:
say “A friendly sounding old voice says ‘Better turn that thing off to save it for later.’”;
otherwise:
say “Leaving it on is a good idea!”.

Instead of examining the flashlight:
test flashlight.[/code]

Edit: I made a small change to simplify the test case - “switched on” utilizes built-in properties of a device.

Edit edit: You won’t be able to copy and paste directly from the code to the example. You’ll need to “quote” my post (button on lower right hand side of the post) and then copy from within the area marked (with square brackets).

I think you have this:

When using “colon and indentation” Inform requires exactly one tab-stop before the first line of the code block (the code block is everything after the name of the phrase, i.e. everything after “To Test Flashlight:”).
It seems that you have two tab-stops there.
This should work:

<tab>	To Test Flashlight:
<tab>	if the flashlight is on: 
<tab>	<tab>	say "A friendly sounding old voice says Better turn that thing off to save it for later";
<tab>	otherwise:
<tab>	<tab>	say "Leaving it on is a good idea!".

(Inform doesn’t care about the number of tab-stops before the phrase-name.)

Alternatively you could write:

	To Test Flashlight:
		if the flashlight is on, say "A friendly sounding old voice says Better turn that thing off to save it for later";
		otherwise say "Leaving it on is a good idea!".

Which (I think) doesn’t count as “colon and indentation syntax”.

I round the problem. I had assumed the tab alignment was relative to the if statement and that the if could be anywhere. - Not so, the if must start in column 0(1). Not very conducive to good readable alignment, but if that is the way it has been designed then who am I to complain? :unamused: