Create account / Log in

Dynamic Property Expression Problem

Talk about module design ideas and techniques.

Moderators: Tim M, uckelman

Dynamic Property Expression Problem

Postby harm » May 2nd, 2018, 10:12 am

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?
harm
 
Posts: 47
Joined: March 24th, 2011, 1:12 pm

Re: Dynamic Property Expression Problem

Postby Brent Easton » May 7th, 2018, 7:00 am

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.
User avatar
Brent Easton
 
Posts: 2733
Joined: December 21st, 2007, 3:06 am
Location: Berry, NSW, Australia

Re: Dynamic Property Expression Problem

Postby Brent Easton » May 7th, 2018, 7:18 am

PS. I would also use more parentheses to guarantee the order of execution of the && and ||'s in the expression.
User avatar
Brent Easton
 
Posts: 2733
Joined: December 21st, 2007, 3:06 am
Location: Berry, NSW, Australia

Re: Dynamic Property Expression Problem

Postby harm » May 14th, 2018, 9:38 am

Many thanks, Brent.

Works perfectly.

Best,

Matthias
harm
 
Posts: 47
Joined: March 24th, 2011, 1:12 pm


Return to Module Design

Who is online

Users browsing this forum: No registered users and 1 guest