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.
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;
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)
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]