Replacing text with formatted text

Is there any way to incorporate text formatting in replacement text?

eg - I hoped the following would make the first Z bold, but it doesn’t.

[code]Test-text is initially “ZZZ”.

BOLDED Z is initially “[bold type]Z[roman type]”;

When play begins:
replace character number 1 in Test-text with BOLDED Z;
say Test-text.[/code]
I’ve tried lots of sleights of hand (temp variables, real variables, ‘saying’ things) but when using a ‘replace the text/character’ command, none of them seem to work. The replacing text always comes out plain.

This is a follow-on from my ‘slowdown’ topic. I 'm trying to replace a letter or two in a text with “[bold type]THE LETTER OR TWO[roman type]”. Really, I’m trying to optionally replace it with bold type, but I can’t get any kind of text formatting to carry over.

Any ideas? Thanks.

-Wade

The problem is the two types of text: indexed (substituted) text is a plain array of characters, while normal (unsubstituted) text is a routine which prints all the components (including subroutine calls for formatting and such). Doing a replacement forces it into indexed text, since there’s no meaningful way to make changes to the text while preserving [at random] or such. So this also kills the formatting.

Thanks again. Ugh, when they said all texts were now alike, they lied!

OK, I came up with workaround. No more using replacements. I capture the phrase in 3 parts (before the tilde, the letter after the tilde, then everything after that) with one reg ex expression, then say the 3 parts back one after another, dropping formatting statements inbetween parts as desired. So long as I still only use one reg ex search per line, it seems no slower than the previous method.

-Wade

This works for me:

Test-text is initially "ZZZ".

BOLDED Z is initially "[bold type]Z[roman type]";

When play begins:
	if Test-text matches the regular expression ".(.*)":
		now Test-text is "[BOLDED Z][text matching subexpression 1]";
	say Test-text.

This keeps everything as unindexed text so you don’t lose the formatting.

Okay maybe I’m missing something but isn’t he talking about §20.4 ?[code]giggity is text that varies. giggity is initially “giGGity GiggiTy GOO”.

When play begins:
say “[giggity] / [giggity in title case] / [giggity in lower case] / [giggity in upper case] / [giggity in sentence case]”;[/code]

Ah. Damn. Went over this again and again and it wasn’t until AFTER I hit submit that I instantaneously notice that it’s to bold, not to capitalize.

How about making a throwaway text object that you use as the first letter of the text you want to bold the first letter of, you remove the first letter of the actual object, and then you make the actual object the substituted form of “[bold type][throwaway][roman type][actualthing]” ?

So, you’re doing miniatures, aren’t you? … Silly they’re called that when they’re bigger than the rest of the text.

Wes, the previous version of Inform distinguished between indexed texts and, uh, regular(?) texts.

Anyway, in 6L38, you no longer have to tell Inform which kind you want, but it will turn your text into the appropriate kind out of the two, under the hood, depending on what you’re doing with it.

As soon as you use a command involving the word ‘replace’, you’re dealing with indexed texts, and they don’t hold formatting.

-Wade

Then i’ll go withto say wobble: say "[bold type][throwaway][roman type][actualthing]";