threefold action i7

If I were to use include (–) in i7, could I make a three fold action? I’m not asking how to, I’m asking if it’s possible.
EDIT it would be something like this: [code]Include(- global third; [thirdnoun x; x = parsetoken(elementarytt,noun_token; if(x==gpr_fail or gpr_reparse) return x; third =x; return gpr_preposition; ]:wink:

The room top is a room.[/code]

You’re quoting exercise 91 of the Inform 6 manual (inform-fiction.org/manual/html/sa6.html#ans91). Although you have a couple of typos which prevent it from compiling.

I’m not sure anybody has tested this solution with I7. It should be possible, in principle. However, you’re going to have a hard time inserting the general parsing function ThirdNoun into a grammar line. I don’t know a way to do that.

Oh, there is a way. I should have checked the docs first.

This works:

The Kitchen is a room.

The player carries a rock.
The player carries a stone.
The player carries a pebble.

Include (-
Global third;
-) after "ICL Commands" in "Output.i6t".

The third noun is an object that varies.
The third noun variable translates into I6 as "third".

Include(-
[ ThirdNoun x; 
	x = ParseToken(ELEMENTARY_TT, NOUN_TOKEN);
	if (x == GPR_FAIL or GPR_REPARSE) return x;
	third = x; return GPR_PREPOSITION;
];
-).

The Understand token third-noun translates into I6 as "ThirdNoun".

Combining it with is an action applying to two things.

Understand "combine [something] with [something] with [third-noun]" as combining it with.

Report combining it with:
	say "Combined [the noun] with [the second noun] with [the third noun]."

Test me with "combine rock with stone with pebble".

Note that the action is defined as “applying to two things”. I7 doesn’t understand that there’s a third noun, so you have to write it that way.

Of course, the third noun variable won’t be wrapped up into stored actions or reset between turns the way noun and second noun are. You’ll have to be careful with it.

There was a bit more discussion here.

Could you use this to match text as well?

I had originally figured I would have to define the action in i6 and then translate into i7. However, the way you put here is much better.

This looks very useful! Can similar code be used to make an action apply to two values?