Problem with substring reporting error in log but working right on counter

Calculated Properties are also ignored on the Palette, in case that helps track the cause down.

OK, this is another version of what used to happen with Calculated Properties. During building of the Piece Slot, the Piece is built out from it’s prototypes, but if a Calculated Property is referenced in a Text Label, it causes the CP to be evaluated. If the CP references properties in deeper protoytype levels that have not been expanded yet, it can cause a Bad Data in Module error, if you take a substring of what is now an empty String for instance.

We ‘solved’ this using the fairly heavy-handed approach of not evaluating a CP on counters that are in a GamePiece palette.

The counters in this module use {} expressions within Text Label formats (Aside: This is generally not a good idea if your module has many counters with labels doing this, you may find that general performance is affected). Any {} expression is essentially an in-line Calculated Property, so the same problem occurs when used in Text Labels.

I could use the same approach (not evaluate Text Labels in Palettes), but that would be heavy-handed as it shuts down labels that actually work. I can see a better approach that just evaluates Labels in Palettes ‘quietly’ and ignores errors.

I could also apply this technique to Calculated Properties and turn these back ‘on’ in the palette, just suppress errors.

Could you (and Mark) please try out the test build 13490-PaletteErrors going up now in http://vassalengine.org/build.

Check that it solves the problem, but that your module still works :slight_smile:

I believe this resolves the problem, plus I have turned evaluation of Calculated Properties in GamePiece Palettes back on, but have suppressed the error reporting on these as well. It’s a much better solution.

CCN v5 looks like it still works. I don’t have a ready replica of bad data module errors, so I haven’t tested that as yet.

Hi Mark and Brent I can get to the code but I need to download an executable for Mac. I can get the code, but have no idea how to run it from there

"Aside: This is generally not a good idea if your module has many counters with labels doing this, you may find that general performance is affected’

I agree. If there were that array command then I don’t think I would need to evaluate. I could just get the nth item in the array. I realize this is a labor of love and I don’t reasonably expect that to show up but that is why I want it.

Thank you again for the help. Muting the error is a great solution AFIK.

VASSAL-3.8.0-SNAPSHOT-bb76350-13490-PaletteErrors-macos-universal.dmg Should do it.

Even still you would likely have issues. It’s not the complexity of the expression so much as using a Beanshell expression at all. The overheads of using any Calculated Property or {} at all is quite high. You would still need Calculated Expressions to use my proposed Array implementation.