string bug? Using .replace to replace quotation marks

Vassal v3.4.12

I figure that the beanshell expression {name.replace(""","")} ought to return a string that is stripped of any double quotation marks that were present in the dynamic property “name”.

However, instead I get the error, ending in the message:-

Expression evaluation error {name.replace(""","")}

Hi Mark.

It’s not the quotes. There seems to be a more general problem with applying String functions to property names that I though I had resolved.

The work-around is to go back to using

{GetProperty("name").replace("\"","")}

I am investigating.

Regards,
Brent.

I believe I have tracked down the problem. The expression itself is correct, the problem occurs when the property values contains a " character and you then try and apply a string function directly to the property name.

Build VASSAL-3.5.6-SNAPSHOT-e6cf6ba-14368-quotes is up if you are able to test.

Regards,
Brent.

Brent - That builds tests out ok; {name.replace(""","")} now executes without error when there is a double-quote in the property ‘name’.

I still get the following kind of messages as mentioned in my comment on Bugzilla 14368, so that must be a different issue:

[code]- Bad Data in Module: Expression evaluation error Expression={Sum(“TCstate_Level”,"{LocationName=="$LocationName$" && (Type==“Unit” || Type==“Garrison”)}",CurrentMap)>1}, Error=Method Invocation _interp.sum

  • Bad Data in Module: Expression evaluation error Expression={(Count("{LocationName=="$LocationName$" && Type==“MarkTC”}",“Main Map”)==0) && prefRestrictOff!=true}, Error=Method Invocation _interp.count
  • Bad Data in Module: Expression evaluation error Expression={(Count("{LocationName=="$LocationName$" && Type==“Unit” && (Class!=“INF” || Square_Level>1)}",CurrentMap)>0) || ((Count("{LocationName=="$LocationName$" && NoSquare==true}",“Main Map”)>0) && prefRestrictOff!=true)}, Error=Method Invocation _interp.count
  • Bad Data in Module: Expression evaluation error Expression={(Hits>0 || (Count("{LocationName=="$LocationName$" && Class==“CAV”}",“Main Map”)==0)) && prefRestrictOff!=true}, Error=Method Invocation _interp.count[/code]

Update: I tried making a test module for the spurious expression errors. I can’t reproduce the error in a test case so far. Whatever error there may be, it is something more than simply using the expression in the Restricted Commands trait or the other basic characteristics that I’ve replicated from my “live” case in the test module. I will go back to trying to fix it in the module and maybe find out more that way.