If this or this or this or this then that....

I can seem to get some kind of “If this or this than that” switch to work. I want to be able to collect a word at the end of an indexed text, but collect two words if the last word is one of for choices. Here’s an example.

The indexed words can be one of these four situations.

“broken nail”
“blue pen”
“happy dog”
“green grass”

So here is some code… (This may or not compile, I’m writing this off the cuff)

Let the example be indexed text.
Let the example be "green grass".
Let the last position be the number of words in the example;
Let last word be word number (last position) in the example; [parentheses are for clarity]
[This what I'm trying to accomplish - Something like the code below]
If the last word is "grass" or "pen":
     Let color be word number (last position - 1) in the example;
else
     say "That object is colorless"

Now, this is just a silly example. I’m not actually trying to find the color of something by what noun it is. It’s more of an exercise to collect the word previous if the last word matches something particular.

I’m having problems finding how to use the “if” command with logical operators (and, or, not)

You can’t abbreviate the conditions. You have to write them in full.

If the last word is "grass" or the last word is "pen": ...

In other words, each part of the condition must work as an independent condition (you can’t say ‘If “pen”:’, for example).

So like…

If the last word is "grass" or if the last word is "pen":

all written out?

It seems “else” is called “otherwise” in Inform.

The code logically should be like this?

If the last word is "grass" or if the last word is "pen":
     Let color be word number (last position - 1) in the example;
otherwise
     say "That object is colorless"

this doesn’t work either…

No, don’t repeat the if. “If the last word is “grass” or the last word is “pen”: …”

I think you also need a colon after “otherwise.”

“Else” and “otherwise” are synonymous for Inform 7 purposes.
(Graham apparently favours “otherwise”. Perhaps it results in more idiomatic (British?) English?)

I think “otherwise” does result in more idiomatic (American) English, though it sounds slightly formal. The inclusion of “else” might be a concession to programmers who are used to saying “If… then… else…”

[rant=the following is a discussion of English idiom which could be very confusing if you try to apply it to inform]What’s most natural to me in spoken English is probably “or else.” So I might say something like “If you want to get get gas before the trip, we should turn left here, or else we can just go straight to the highway.” But I think including “or else” as an acceptable syntax would just be incredibly confusing, because of the usual meanings of “or.”[/rant]

In this situation, I’d use “otherwise” rather than “or else” (and no comma). It reads smoother from my point of view. It’s probably something that depends on one’s taste.