I7: Concatenating strings

What’s the proper way to concatenate strings in Inform 7, particularly if you’re building a statement and want to append things to it?

I think you just write them one after another as indexed text. The following seems to work:

[code]Carritorium is a room.

To decide what indexed text is the concatenated holdings of the player:
if the player carries nothing:
decide on “un”;
let T be indexed text;
repeat with item running through things held by the player:
let T be “[T][printed name of item]”; [This is what you’re looking for, I think.]
decide on T.

Instead of examining the player: say “You are [concatenated holdings of the player]laden.”

A ball, a bat, a cat, a pall, and a hossenfeffer are in Carritorium.

Test me with “take all/ x me”.[/code]

Why does “let (variable) be…” work with that, when “now (variable) is…” causes an overflow error?

[code]The Newsroom is a room.

The news report is some text that varies. The news report is "And now for the news. ".

Every turn:
now the news report is “[news report]No news to report.”;
say the news report.[/code]

You need to use “indexed text” for this – not regular “text.”

Not to negate the question, but there are often ways to do what you want without genuinely concatenating strings.

Yeah, I didn’t mean to imply you need indexed text – just that you do if you want to actually concatenate the strings. Here’s one way of doing it with regular text:

[code]The Newsroom is a room. Revealed stories is a number that varies.

Table of News
"Story 1. "
"Story 2. "
"Story 3. "

Every turn:
unless revealed stories is the number of rows in the Table of News, increase revealed stories by one;
say “And now for the news. [news report]”.

To say news report:
if revealed stories is 0:
say “No news to report.”;
repeat with N running from 1 to revealed stories:
choose row N in the Table of News;
say “[story entry]”;
say paragraph break.

test me with “z/z/z/z”.

^That is indeed the better way; I was just inclined to try concatenation because a) I needed to append a variable number of strings and b) I had concatenation on the brain.

As far as item “a” goes, you can always make say-phrases recursive, or at least nested.