In a piece, the general idea is to have a lot of check on when it ends its move, and then having a last actions that sends it back if all the previous checks failed.
So, if i were programming, i will write a code like
if (LocationName==”ZoneA”) do ActionA else if (LocationName==”ZoneB”) do ActionB else if (LocationName==”ZoneC”) do ActionC else if (LocationName==”ZoneD”) do ActionD else if (LocationName==”ZoneE”) do ActionE else return to OldLocation
Now, i’m able to do the all the Trigger Action traits, but how can i implement the final “else” statement?
(without writing all the previous test but negated, as i may need to add more and i’d like to avoid to have to always update also the last one)
Use the Java ternary expression, ?:, instead of if statements. Your example would be: {LocationName == “ZoneA” ? ActionA : LocationName == “ZoneB” ? ActionB : LocationName == “ZoneC” ? ActionC : LocationName == “ZoneD” ? ActionD : LocationName == “ZoneE” ? ActionE : ReturnToOldLocation}(leave out the opening and closing braces if you’re using this in a Calculated Property).
Edit: OK, I re-read your initial question, and you want a Trigger Action that only triggers if none of the others do. To do that, you would need use a “flag” Dynamic Property with a wrapping Trigger Action around the others. Basically, the new Trigger Action would set the flag DP to false, then call each of the “Zone” trigger actions. The “Zone” trigger actions would set the flag DP to true (in addition to doing the appropriate action). Finally, the wrapping trigger action would call the “else” Trigger Action, which would be set to only fire if the flag DP is still false. (Important edit to the end of that last sentence; I had the logic backwards!)
Yeah, but this is exactly what i’d liked to avoid (i tried to explain with my poor english:)
In the end, I find the first idea the better, also thanks to the fact that the Calculated Property field retains empty lines and multiple spaces, so i can have it like this: