
Re: Global status variable for all DS10A Window Sensors
kalan wrote:...
Maybe someone could help me fix the end of this script to set a global variable (called "SecurityStatus") to true or false based on the status of all 12 DS10As. If any one of them is open (false state) then SecurityStatus will be false. Alternatively SecurityStatus can only be true if all DS10A states are true. As it's currently written, an open window would set the global variable SecruityStatus to false but closing one would set it to true even though there may still be an open window somewhere else. I have to fix this loophole in the logic.
...
If your variables are defined as booleans, could you not just AND them all together? If they are all 'true', the result would be 'true'. If one was 'false', the result would be 'false'.
Or if you put all your variables in a list, then maybe something like:
>> set varList to {SlidingDoor, SlidingDoor, BedRoomWindow1, BedRoomWindow2, BedRoomWindow3, BathWindow, FrontDoor, DenWindow, LivingRoomWindow1, LivingRoomWindow2, KitchenWindow, BackDoor, ROOMBA}
>> set SecurityStatus to not (varList contains {false})
Richard