3.5.5 Expression builder locks up with too many ? :

Previously, I encountered the bug where beanshell If() expressions became agonizingly slow when you when about 10 deep or so. At that time, the fix was to use ? :

Now, going about 10 deep in ? : causes the expression builder to lock up. Haven’t tested whether it locks up a running game yet.

No error log, because no error… yet. Just waiting to be able to close the expression builder so I can use the editor again.

The expression builder never recovered. Another hour or so of progress lost.

I have a module with an expression with about eight ?: in sequence. I edited it to add another six and didn’t get a hang.

There was a recent thread /discussion involving lots of brackets causing the expression evaluation to go really slowly. I don’t suppose that’s relevant here?

Are you able to share the exact expression that causes a problem?

It was just CurrentX<1249 ? 1 : CurrentX<1506 ? 2 : etc. as the value of a Dynamic Property.

Building the expression through prompts was fine, up to 18 deep, but clicking OK to go back down to the base ? : hung at around the 10th OK.

Writing the expression in text, pasting into the DP, then clicking the expression builder to confirm it was OK also hung for an hour or more before I used task manager to kill it.

Yes, there does seem to be an issue with the beanshell parser and its handling of deeply nested ? : expressions. Especially if you include additional unnecessary parentheses. After investigating this, I don’t believe it is something I will be able to fix.

Could you please post the exact text of the expression you are trying to paste in so we can comment.

I am looking into an alternative for V3.6 that will allow you to create ‘Lookup Tables’ to implement various types of ‘Switch’, ‘Case’, ‘Code Lookup/Conversion’, ‘2D Table Lookup’ constructs via a Beanshell function. Create a Lookup Table named “tab” as a component, then reference it using {lookup(“tab”, value)}.

It appears that ignoring the expression builder entirely and removing all brackets gives some performance gains. In any case I split it into multiple triggers now, so the ? : calculation only goes 6 deep for each.

Current example is
{CurrentX<1097 ? 1 : CurrentX<1433 ? 2 : CurrentX<1765 ? 3 : CurrentX<2099 ? 4 : CurrentX<2432 ? 5 : 6}

Previously that went up to 18, and had all the brackets the expression builder added.

I’d still like to see the full, problematic expression.

Can’t remember now, but I think the expression builder by default makes:

(((CurrentX<1097) ? 1 : ((CurrentX<1433) ? 2 : ((CurrentX<1765) ? 3 : ((CurrentX<2099) ? 4 : ((CurrentX<2432) ? 5 : 6)))))))

Just keep going for another 12 iterations. Lots of brackets.

I can’t reproduce it to check, because it hangs indefinitely.

Try this (or rather, the version of it that goes on for 12 iterations…
for all I know, you don’t need any brackets at all, but I think it is the cumulative nested brackets that are the problem…

(CurrentX<1097) ? 1 : (CurrentX<1433) ? 2 : (CurrentX<1765) ? 3 : (CurrentX<2099) ? 4 : (CurrentX<2432) ? 5 : 6

You don’t need any brackets, as per my previous post. And yes, it does seem like the brackets the expression builder inserts are the problem.

Sorry, I missed that you already found that solution.