Trouble with paragraph breaks

I’ve run into a strange issue while trying to combine [run paragraph on] with [paragraph break]. (I’m using 6M62, if that matters.) Here’s a minimal example to show what’s going on:

"Test"

The Adventure Lab is a room.

A-testing is an action applying to nothing. Understand "a" as a-testing.
Carry out a-testing:
    say "[c-test] Okay.[paragraph break]";
    say "Here we go."

B-testing is an action applying to nothing. Understand "b" as b-testing.
Carry out b-testing:
    say "Okay.[paragraph break]";
    say "Here we go."

To say c-test: say "Let's do this.[run paragraph on]"

This produces the following output:

>a
Let's do this. Okay.
Here we go.

>b
Okay.

Here we go.

What I expected was that [run paragraph on] would have an effect only at the point where it appears, preventing the line break that would otherwise appear after “Let’s do this.” Instead, it seems to be spreading its effect over the whole paragraph, somehow cancelling out the [paragraph break] that appears later. The desired output would be:

>a
Let's do this. Okay.

Here we go.

The documentation, as usual, is a little vague about how exactly these spacing commands work. My usual recourse at this point is to look in the Standard Rules, but the spacing commands are just defined there by calling an I6 routine, and tracing them further is beyond my skill. However, there should be some way to prevent a paragraph break after one sentence and force a paragraph break one sentence later. What gives?

2 Likes

Have you tried splitting

    say "[c-test] Okay.[paragraph break]";

into

    say "[c-test] ";
    say "Okay.[paragraph break]";

so that [run paragraph on] won’t affect the end of Okay. part of the line?

Edit: added bold part.

1 Like

I can’t take credit for this. I think I saw Zed do it first, but I just do text substitutions for troublesome line breaks (this is unicode for a period/full stop symbol):

To say dot:
	say "[unicode 46]".

I think there is a logic to the way breaks work, but I never got the hang of it. Exclamation points and question marks can lead to similar behavior.

2 Likes

The correct way to suppress a line break after mid-line punctuation is:

To say c-test: say "Let's do this.[no line break]"

See WI §5.8. Line breaks and paragraph breaks

2 Likes

This works! Thanks for supplying the should-have-been-obvious-but-didn’t-occur-to-me idea.

Doing text substitutions for punctuation marks might work as well, e.g. in the example I can get the desired output with

To say c-test: say "Let's do this[unicode 46]".

but I worry that obfuscating punctuation is a short path to madness, especially in a project that already has a large number of complex text substitutions.

It seems that [no line break] and [run paragraph on] are subtly different, and the documentation isn’t very helpful in determining which one is correct. (I don’t remember the specifics at this point, but I’ve run into cases where [no line break] did nothing at all and [run paragraph on] worked perfectly.)

These might also work:

say "[c-test] Okay.[line break][paragraph break]";

or

say "[c-test] Okay.[line break][line break]";

or

say "[c-test] Okay.[no line break]";
say "[paragraph break]";
To say period -- running on:
	(- print "."; -).

To say c-test: say "Let's do this[period]".

Somewhat less mad.

2 Likes

That’s interesting, I hadn’t clocked the -- running on syntax before.

As far as I can see from Basic Inform, including it in a say statement is the equivalent of a preceding [no line break] in substituted text:

To say no line break -- running on
	(documented at phs_nolinebreak):
	do nothing.

i.e. it is a signal to the compiler ‘If you were about to compile a hard-coded new_line statement at this point* don’t.’

*e.g. if the last character just printed was a period, question mark, or exclamation mark AND

  • this printing routine is about to finish OR
  • it’s about to go on to print other stuff from a separate routine (perhaps via a text substitution) without any intervening white space

EDIT: so

say "Hello.[no line break][interjection]".
To say interjection: say " How are you?".

is equivalent to:

say "Hello.[interjection]".
To say interjection -- running on: say " How are you?".

but this doesn’t work:

say "Hello.[interjection]".
To say interjection: say "[no line break] How are you?".

in the case of To say no line break -- running on: do nothing. the -- running on - prefaced [no line break] substitution prints nothing- it exists purely to send this ‘no hard-coded line break here’ signal to the compiler.

in the case of To say period -- running on: (- print "."; -). the text substitution [period] prints a period, but-- running on ensures that in the case of “Hello![period]” it is printed as

Hello!.

not

Hello!
.

Note that using I6 to print the substitution:
To say period: (- print "."; -).
is the thing that ensures a line break isn’t triggered AFTER the substitution, as would be the case for
To say period: say ".".
-- running on
is the thing that ensures a line break isn’t triggered by punctuation immediately BEFORE the substitution.

so there are four possible ways of defining say period: with or without using I6 and with or without using – running on, with the following possible results to, for example

say "Hello![period] How are you?[period] she said.[paragraph break]";
To say period: say "."
[line break before and after the substitution]

Hello!
.
How are you?
.
she said.

To say period -- running on: say "."
[line break after but not before the substitution]

Hello!.
How are you?.
she said.

To say period: (- print "."; -)
[line break before but not after the substitution]

Hello!
. How are you?
. she said.

To say period -- running on: (- print "."; -).
[no line break before or after the substitution]

Hello!. How are you?. she said.

EDIT

PS. for those with an aversion to I6 inclusions, you can achieve the same result with

To say period -- running on: say "[unicode 46]".

where the use of a say "[unicode 46]" substitution instead of say "." does the job of suppressing a line break AFTER [period],

4 Likes