Capitalizing a substitution

Okay… I have a substitution which I use occasionally, let’s say it sometimes generates “red…blue” as if a color were changing. This substitution sometimes appears at the beginning of a sentence and I want it capitalized.

I’ve tried several methods for capitalizing it (short of duplicating the original substitution routine with capital letters built in) and nothing works. I’m sure that some of my difficulty has to do with my completely inability to understand the difference between indexed and non-indexed text (or the point of that difference) but the real problem is this:

When I got SOMETHING sorta working, it gave me a bum response: “Red?”

I’m assuming this has to do with the ellipsis and Inform’s desire to essentially capitalize the first words of two nonexistent sentences. Any suggestions?

I thought about pulling out the first letter for capitalization and recombining, but that would require either replacing a SINGLE character in a string, or pulling out a RANGE of characters --chars 2 to (the number of characters in the string)-- both things that seem to be impossible in Inform.

What the hell?! I’ve blown a day here… I could have done this in HyperText in 2 seconds!!

Does this work?

To say your text substitution: [your code goes here]. To say Your text substitution: let T be indexed text; let T be "[your text substitution]" in sentence case; say T.

And then you can say “[your text substitution]” and “[Your text substitution]” as you wish.

“In sentence case” automatically uppercases the first character and lowercases everything else, which can be a problem if you have internal capital letters, but seems like what you want if you don’t. See section 19.4 of the documentation.

…and from what Graham said about the next update, it sounds like pretty soon we won’t have to worry about the difference between text and indexed text at all.

Hmm… that’s pretty much where I was before, and I’m still getting an erroneous response…

But I think the bad response was because of an automatic text substitution happening at the system level… replacing three periods with the ellipsis character U+2026, which Inform chokes on. I HATE auto-substitution of that character, and I’ll try to turn it off, but it would be swell if Inform recognized it.

Thanks for the help!

Hm, I put three periods into the indexed text I was trying to do this with and I didn’t have that problem. But the letter after the ellipsis did get turned into a capital letter, which was annoying. So I tried this:

To say Name associated with (coordinate - a number): let T be indexed text; let T be "[name associated with the coordinate]"; replace character number 1 in T with character number 1 in T in upper case; say T.

and it seems to be working. If you post your code or a reduced version that recreates the problem, I can try to look at it.

…or was it that you’re composing in at text editor/word processor that converts the dots into ellipses, rather than something Inform is doing?

Huh! I couldn’t figure out how to do a single character replacement on my own. The documentation sometimes feels a like it’s written for one specific mind… like… I don’t know… Chapterhouse: Dune or something.

Turns out that I don’t mind the errant capitalization after the ellipsis. It works for me in this case. By the way, the problem isn’t three periods, it’s only the ellipsis CHARACTER, which I’d be happy to do away with entirely. (The only place where it’s any use to me is in Final Draft, where–because Courier is a monospaced font–that character often keeps me from rolling over into the next line.)

Thanks for the solution!