Dynamic Property Expression Problem

Both of the two following expressions are accepted by the expression builder, alas neither of the two work properly, resulting always in the else effect:

{If($CurrentZone$CCP==0&&$CurrentZone$JAP==0||
$CurrentZone$CCP!=0&&$CurrentZone$JAP==0&&$CurrentZone$KMT==0||
$CurrentZone$JAP!=0&&$CurrentZone$CCP==0&&$CurrentZone$KMT==0,2,1)}

{If(GetProperty($CurrentZone$CCP)==0&&GetProperty($CurrentZone$JAP)==0||
GetProperty($CurrentZone$CCP)!=0&&GetProperty($CurrentZone$JAP)==0&&GetProperty($CurrentZone$KMT)==0||
GetProperty($CurrentZone$CCP)==0&&GetProperty($CurrentZone$JAP)!=0&&
GetProperty($CurrentZone$KMT)==0,1,2)}

Any ideas?

The GetProperty function requires the name of a property as a string, so I think what you need is

{If(GetProperty("$CurrentZone$CCP")==0&&GetProperty("$CurrentZone$JAP")==0||
GetProperty("$CurrentZone$CCP")!=0&&GetProperty("$CurrentZone$JAP")==0&&GetProperty("$CurrentZone$KMT")==0||
GetProperty("$CurrentZone$CCP")==0&&GetProperty("$CurrentZone$JAP")!=0&&
GetProperty("$CurrentZone$KMT")==0,1,2)}

If $CurrentZone contains “X” and the property XCCP contains “0” then

  • GetProperty("$CurrentZone$CCP") get’s the value of the property names XCCP and return 0.
  • GetProperty($CurrentZone$CCP) is trying to get the value of the property whose name is stored in the property names XCCP and do is returning the value of a property named “0”, which should generate an error.

Mixing $$ markers and Expressions is fraught with danger. A better syntax to use would be

{If(GetProperty(CurrentZone+“CCP”)==0&&GetProperty(CurrentZone+“JAP”)==0|| …

Regards,
Brent.

PS. I would also use more parentheses to guarantee the order of execution of the && and ||'s in the expression.

Many thanks, Brent.

Works perfectly.

Best,

Matthias