Conditional Usage

How come this works: ((afgan==“chinat”||afgan==“chicom”||afgan==“minor”) ? “China FP” : (afgan + " FP"))

But this ((afgan==“chinat”||“chicom”||“minor”) ? “China FP” : (afgan + " FP")) or this
((afgan==(“chinat”||“chicom”||“minor”)) ? “China FP” : (afgan + " FP")) do not work

error message: Error= inline evaluation of: ``_xyzzy=_plugh();’’ internal Error: Unimplemented binary String operator

Both got the green tick for expression.

Not sure why you got the green tick, because those are just flat out wrong: “||” is a logical-or operator; it expects something that evaluates to true or false as its operands. A string (e.g., “chicom”) does not evaluate to true or false (whereas afgan==“chinat” does), so you get an error.

What you can do instead is use a regular expression evaluation: {afgan =~ “(chinat|chicom|minor)” ? “China FP” : afgan + " FP"} (those parentheses shouldn’t be necessary, actually–try without them if you still get an error).

Google regular expressions if you want to understand more about how to use them (specifically, Java regular expressions).

Thank you. I just went ahead with the one that worked. As for the green tick appearing for the others then maybe there is a bug with the vassal expression builder error checking.

No, no bug.

The green tick indicates that the ‘form’ or ‘syntax’ of the expression is correct, but it makes no attempt to run or evaluate the expression, since we can’t know what values any properties might have at this point when you are editing the module.

So it is perfectly possible to create correct looking expressions that fail to run when values are plugged into all properties