I'll never get tired of repeating this: /echo is your best friend. Stick one in front of your commands or in front of specific identifiers, then look at what is printed.
I'm guessing here, but $did($dname,1).sel may not return what you think. To make sure, just print it in your Status with /echo:
echo -s $!did().sel returned: $did($dname,1).sel