I7: Combining string variables?

It’s time for me to ask for help.

I can’t figure out how to combine string variables in I7. What I want is to combine two pieces of text together and drop them in a third piece of text. Some fake example code is below (and that last line most definitely doesn’t compile - it’s just to show what I’m trying to do).


The first sentence is some text that varies. The first sentence is “To be, or not to be?”
The second sentence is some text that varies. The second sentence is “That is the question.”
The third sentence is some text that varies.

To compose Hamlet’s quip:
now the third sentence is (the first sentence plus " " plus the second sentence).


Let us assume, for the sake of this example, that I am compiling a great number of quips and it is very ineffective to use a different variable for each one (so "now the third sentence is “[the first sentence] [the second sentence]” would not do, since the meaning will be lost when I change the value in those variables.)

What’s the correct way to do this? Is it even possible?

Carolyn

Indexed text does this. If you have:

The third sentence is some indexed text that varies.
now the third sentence is “[the first sentence] [the second sentence]”.

…that will do what you want; an indexed text variable is “rendered” when it’s set.

Ah-hah! That is extremely helpful.

Now, suppose (because the first example was fairly terrible in view of my ultimate goal) that I wanted to take the first sentence, combine it with the second sentence, and then apply it to an item description. I understand that item descriptions are text, not indexed text. Would something like this be the answer?


A Hamlet T-shirt is a wearable thing. A Hamlet T-shirt has some indexed text called the visual. Instead of examining the Hamlet T-shirt: say the visual of the Hamlet shirt.

The first sentence is some text that varies. The first sentence is “To be, or not to be?”
The second sentence is some text that varies. The second sentence is “That is the question.”

To prepare the shirt description:
now the visual of the Hamlet shirt is “The shirt reads: ‘[first sentence] [second sentence]’”.

I believe this works. I’m unsure of the performance effects of using a function v. using indexed text, but generally I feel it’s ‘cleaner’ to use substitutions and ‘to say’ functions in order to build adaptive prose, rather than the lower-level operations involved in indexed text.

"Some text that varies"

The opening sentence is some text that varies.

The closing sentence is some text that varies.

To say full sentence: say "[opening sentence] [closing sentence]"

The Variant Room is a room. "A placard reads, '[full sentence]'"

When play begins:
	now the opening sentence is "Bob's";
	now the closing sentence is " your uncle!"

Fizbo is an action applying to nothing.
Understand "fizbo" as fizbo.

Carry out fizbo:
	now the opening sentence is "[one of]Robert[or]Jonah[or]Chris[or]Mark[at random]'s";
	now the closing sentence is "your [one of]uncle[or]roommate[or]grief counselor[at random]!"

Report fizbo:
	say "You feel a tingle run up your spine."
	
Test me with "fizbo / look / fizbo / look".
A Hamlet T-shirt is a wearable thing. A Hamlet T-shirt has some indexed text called the visual. Instead of examining the Hamlet T-shirt: say the visual of the Hamlet shirt.

That will work. Or you could set the description of the shirt to “[visual of the shirt]”, although that brings up some line-break hassles.

Oh, gah, I think I rather misunderstood what the original poster was trying to accomplish. :blush:

Thanks for your help.

I’ve started using rulebooks for complicated text pastiche. You could have a caption rulebook:

(not tested):

[code]Caption is an object-based rulebook.

Caption of the T-shirt (this is the first sentence rule):
say “To be, or not to be?”;

Caption of the T-shirt (this is the second sentence rule):
say “That is the question.”;

Instead of examining the T-shirt:
follow the caption of the T-shirt.[/code]
There are definite line-break hassles, but I really like the way the source looks once I get it working. And there’s no indexed text!

I’ve also considered doing things like this with activities, but so far that’s seemed unnecessarily verbose. I like the way rulebooks can be named to blend in with the code in a “natural language” way.