I7: Attempting to compare indexed text to table entries

I have some indexed text, that I got by performing various regex stuff on the “topic understood,” and now I want see if that indexed text matches some text in a table. But I can’t seem to make that comparison, since they are different types (and honestly I’m a little shaky on “matches” versus “is listed” for this case).

So, here’s a simplified example:

Table 1
Topic
"duck"
"boat/skiff/sailboat"
"flower/daisy/posy"

Floobling is an action applying to one topic.
Understand "flooble [text]" as floobling.

Carry out floobling:
	let thingtoflooble be indexed text;
	let floobler be indexed text;
	if the topic understood matches the regular expression ".*((?= with)":
		let thingtoflooble be "[text matching regular expression]";
		if the topic understood matches the regular expression "(?<=with )).*":	
			let floobler be "[text matching regular expression]"; [alternate forms of the flooble grammar would be here]
	[here's the part that doesn't work:]
	if thingtoflooble is a topic listed in Table 1:
		say "Now there's a thing I know how to flooble!";
	else:
		say "If such a thing exists, I don't know how to flooble it."

The compiler complains, naturally, that

I know that indexed text can’t just be magically turned back into text (or at least, the docs emphasize this), but it seems like there should be a way to compare the two, so I’m clearly missing something. Telling the table it contains indexed text also seems not to work.

[As a side question: I can “Carry out floobling” but could not figure out how to “Instead of floobling something” – “instead of floobling some text” and “instead of floobling a topic” also seem not to work. What’s the generic “instead” for an action involving text?]

[here's the part that doesn't work:] if thingtoflooble is a topic listed in Table 1: say "Now there's a thing I know how to flooble!"; else: say "If such a thing exists, I don't know how to flooble it." Have you tried an explicit repeat loop? repeat through table 1: if thingtoflooble matches the topic entry....I didn’t test that, as I’ve never mixed topics & indexed text before.

It’s just «Instead of floobling, say “No flooble for you!”» The parameter ‘topic understood’ is implicit.

I hadn’t tried it, but I tried it just now and it fails, for the same reason as before.

Aha, thanks! I’d gotten turned around because of the Fido example, which is “naming it with” instead of just “naming,” and therefore has “naming the dog with something.”

Then I’m thinking that indexed text and topics do not mix. Maybe Jesse could prove me wrong. I dunno.

Correct - topics can only be matched against snippets, which always refer to part of the player’s command. You can’t directly match a topic against indexed text.

You can, however, change the player’s command temporarily and then match the topic against that:

To decide whether (txt - indexed text) matches (top - topic): let tmp be indexed text; let tmp be the player's command; change the text of the player's command to txt; let result be whether or not the player's command matches top; change the text of the player's command to tmp; decide on result.

…that’s simultaneously horrible and very helpful. :stuck_out_tongue:

Thanks so much! I probably never would have thought of it.