I don't think there is a 'better' way to accomplish what you are doing there. There are ways that aren't as wide, or can be altered more easily (or dynamically).
Code:
[code]
var %a = 3 4 6 8 10 42
;
var %x = 0, %i = 0, %ii = $numtok(%a,32)
while (%a < %aa) {
inc %a
if ($did($gettok(%a,%i,32)).state == 1) {
%x = 1
break
}
}
if ((!$didwm($dname,2,$did(2,0))) && (%x)) {
did -a $dname 2 $did(2,0)
}
(untested) You can change the contents of %a in another part of your script so that different conditions (checkboxes) can affect the results of the script dynamically.