Finding if a text contains a word?

I want to check if a text contains a keyword and replace it with something else. I’m sure I’m missing something easy.

To determine response: if memo includes "hi": now modtext is "hello"; otherwise: now modtext is memo of slate.

The test you want is:

if memo matches the text "hi":

as in Writing with Inform section 20.5. And if you want to replace the text, look at section 20.8, something like

replace the text "hi" in memo with "hello"

Except, as a warning, you probably want to look for “\bhi\b” as in section 20.6, where \b denotes a word boundary. Otherwise you’ll be turning “which” into “whelloch.”

Anyway, look around those sections of chapter 20 to see what you can do (I’m looking at 6L02 documentation for what difference it makes).

Now, the reason you’re getting confused by this is that the protocol for finding stuff in a text is different from the protocol for finding stuff in the player’s command. As documented in section 18.33, when dealing with the player’s command you write things like:

After reading a command: if the player's command includes "please": say "Please do not say please."; reject the player's command.

The player’s command isn’t actually a text but a snippet, where a snippet is a part (or the whole) of what the player has typed, and is actually just stored as a number that encodes where to start looking in the player’s command and how many words to look at (IIRC). When you’re looking at snippets, you use “includes” where text comparisons use “matches the text,” and you use “matches” where text comparisons use “exactly matches the text.” I find this confusing as hell, but changing it would surely break lots of stuff.

Yeah, I got it to compile, but now I’m using the “nothing” property incorrectly. Might as well drop it - three hours are up.

Aw man, it was an Ectocomp thing? I would seriously be tempted to give myself credit for every second I had spent navigating the includes/matches/exactly matches maze. That always kills me.