if ($did >= 4) && ($did <= 7) did -a $dname 3 $calc($did - 3)
you can simplify it even more
if ($did isnum 4-7 did -a $dname 3 $calc($did - 3)