Extra line return with "to say"

This has been driving me bonkers ever since I started coding with Inform 7:

The foobar is a thing. The foobar can be foo or bar. The description is "[foobar-desc]".

To say foobar-desc:
	if the foobar is foo:
		say "Foo.";
	otherwise:
		say "Bar."

This results in an extra line return after the description text and before the next command line, every single time. Clearly I’m doing something wrong, but if so it’s well-hidden in the documentation.

(And yes, I know that in a simple case like this I can do the if/then in the description field itself without resorting to “To say.” There are times that’s not possible, though, and for those I keep running into that extra-line bug.)

3 Likes

There are smart ways to fix this and dumb ways – the smart ways are too hard for me, so I’d just do the dumb way which is to add an extra space after the periods:

To say foobar-desc:
	if the foobar is foo:
		say "Foo. ";
	otherwise:
		say "Bar. "
7 Likes

That’s so dumb, it’s downright idiotic! But works perfectly — thanks so much.

2 Likes

Another option is to keep the period at the top level:

The foobar is a thing. The foobar can be foo or bar. The description is "[foobar-desc].".

To say foobar-desc:
	if the foobar is foo:
		say "Foo";
	otherwise:
		say "Bar";

This is still pretty dumb, and also turns into a headache if you want one of the options to end with a question mark or other punctuation. But it works a lot of the time.

6 Likes

You can include “[no line break]” at the end of each alternative. See 5.8. Line breaks and paragraph breaks.

To say foobar-desc:
	if the foobar is foo:
		say "Foo.[no line break]";
	otherwise:
		say "Bar.[no line break]".

Or, as zarf wrote while I was typing this, assuming all alternatives end with a full stop, you can of course also put the full stop at the end of the overall description and leave it out of the individual alternatives:

The description is "[foobar-desc].".

To say foobar-desc:
	if the foobar is foo:
		say "Foo";
	otherwise:
		say "Bar".
5 Likes

I think the reasoning is that Inform 7 infers that any text ending with punctuation-close quote is the end of a block - which when generating text from the Standard Rules stylistically is supposed to get an extra carriage-return.

4 Likes

My crude-but-it-works way to say things ending in punctuation without a line break is:

To say ?: say unicode 63.
To say !: say unicode 33.
To say dot: say unicode 46.

then:

if the foobar is foo, say "Foo[dot]";
else say "Bar[dot]";
4 Likes

Another arguably-dumb way:

To say foobar-desc -- running on:

This tells Inform not to put a line break after this text substitution, even if there’s one pending. It’s generally used on formatting commands like [italic type] that you don’t want to interfere with page layout at all.

5 Likes

nah, that one’s clever – you’re out of the club. :stuck_out_tongue_winking_eye:

4 Likes

If you don’t mind a little I6 code, and you plan on doing a lot of description tokens, I always use something like this in my games–

To say period: (- print "."; -);
To say exclam: (- print "!"; -);
To say ellipsis:  (- print "..."; -);
To say qmark:  (- print "?"; -);
To say dqmark:  (- print "??"; -);
To say tqmark:  (- print "???"; -);
To say dper:  (- print ".."; -);
To say texclam:  (- print "!!!"; -).

...
The foobar is a thing. The foobar can be foo or bar. The description is "[foobar-desc]".

To say foobar-desc:
	if the foobar is foo:
		say "Foo[period]";
	otherwise:
		say "Bar[period]".

It will print the blank line after the response, but no extra line(because there is no actual period at the end of the phrase, before the endquote). You could shorten [period] to [per], etc. Good and clean.

Found this in an old file… it’s just shorthand for [no line break]

To say > -- running on: do nothing.

When play begins:
say "No line break![>]";
say "Ta da."
3 Likes