Bug or Feature: Inconsistent Beanshell property type parsing

This may not be new but I just spotted something odd in the way Beanshell is handling property types in the following situation…

Report Format (in a window GKC) includes an in-line calculation e.g. {"Result = " + gp+1 }
If gp=2, the output will be “Result= 21” ; gp is being treated as a string.

I discovered a workaround which forces numeric handling;-
define the Report Format as {"Result = " + (true ? gp+1 : 0) } ; now, if gp=2, the output will be “Result= 3”

I haven’t tested but I assume this will be the same for GKC reports when the GKC is on a piece or for the Report Trait.

Mark

You might even be able to use just {"Result = " + (gp+1)}

Yes, this is the expected behaviour. The operator + is evaluated from left to right, so gp is indeed being treated as a string as you are ‘adding’ it to a String. "Result = " + 2 evaluates to “Result = 2”. Add on another 1 and you get “Result = 21”. This is a natural consequence of the + operator doing double duty as numeric addition and string concatenation in an untyped language.

Brian’s solution of {"Result = " + (gp+1)} is correct to force the gp+1 to be evaluated first.

Thanks both.