Problem - Calculated Property

OK, this one’s getting a bit frustrating.

I’m currently using 3.2 SVN 8224 and I’m having issues with the Calculated Property trait. What I am trying to do is take a value that I have just calculated (NWTotal) and perform an absolute value calculation on it. First I created the NWTotal property and attached the simple expression:

VictoriesTotal-DefeatsTotal

Both of these totals are existing Global Properties at the Module level.

Then I created a second Calculated Property, NWAbsValue, and attached the following expression based on an IF statement:

IF: DefeatsTotal>VictoriesTotal
TRUE: NWTotal+(2*NWTotal)
FALSE: (blank)

Mathematically, the expression for TRUE should provide the absolute value of NWTotal (unless I’m just too tired to think).

PROBLEM: When I finish entering all the data for the conditional IF statement, I click on the OK button which returns me to the main Calculated Property trait box. However, none of the IF statement information that I just entered is shown in the expression field no matter how much I expand the size of the trait box. When I select IF again from the menu, hoping that it will bring up the data I just entered, I get a box of empty fields, thereby forcing me to re-enter all of my information again–which does nothing, as it all disappears again when I hit OK.

I tried an experiment just for kicks and it seems that when I enter a simple expression directly into the main CP trait box, it shows up on the screen and stays there–when I click OK and then re-open this trait’s properties, my expression is present. However, when I enter any data for an IF, ALERT, etc., nothing appears in the expression field of the main trait box to show that I have already entered any expression data. This is REALLY confusing when I go from CP to CP, entering expressions to calculate various housekeeping values, as I cannot always remember what I have already set up and what is awaiting configuration.

Q1: Am I totally missing something obvious as to how the Calculated Properties and the Expression Builder work? I don’t think I’m doing anything strange, but I didn’t write the code, so maybe I’m just entering the information in an invalid manner. Also, I have programming experience in C and Java, and I’ve modified several VASSAL modules for my own use, so I think I understand how to write valid expressions. Am I just missing the obvious here? :blush:

Q2: Is there some way of posting even a rudimentary set of instructions about how to use the Expression Builder? I have several modules that could greatly benefit from all the awesome work you guys have done, but I’m afraid to try anything given these results with my current project. I could continue with my trial-and-error system, but I feel like I will create more mistakes than I solve and I would lose lots of time backtracking later to fix errors. I’ve already contacted mycenae about helping to proofread the next version of the Developer’s Guide, so I’m willing to help with proofing help screens if that speeds things up a bit.

Anything you could suggest or provide would be of immense help. Thanks for all the great work, folks!

A couple of quick things.

  1. There was a bug in the Expression builder where functions (if, Alert etc.) are not inserted into the expression after you enter everything in. The bug was fixed in svn 8232 so, try the latest build. If you don’t see it in the Expression field, it isn’t there. If you get the Green tick, then an expression is syntactically valid and should evaluate.

  2. In an expression, you can do anything you can do in Java, including accessing Java system libraries, so instead of using an additional property to calculate the absolute value, just use

Math.abs(VictoriesTotal, DefeatsTotal)

You should be able to get rid of all the intermediate Dynamic Properties that where needed in the past to.

  1. Expressions and the Expression Builder should be pretty straight-forward, they do what you would expect. You can enter anything you would find in any Java Tutorial with the exception of the extra vassal Functions (If etc.). Use Vassal property names instead of variables, but otherwise, straight Java.

Regards,
Brent.

Brent,

Hey, thanks for the quick reply–that’s a HUGE help!

  1. Aha…I wondered if this was a known bug. I’ll install the latest update.

  2. Wow, that’s better than I had hoped. I have been trying to keep up on the progress of 3.2, but with my on-again-off-again move, I’ve been losing track of updates.

  3. The development teams seems to have included an enormous amount of flexibility into the Expression Builder which is a great boon for all of us. I cannot begin to think of how many problems this solves for me in another module that is in progress. This opens a crazy amount of doors when it comes to saving time and effort.

Thanks yet again for all the great work! I’m pumped! 8)