For your init, why not just use:

did -c $dname 25 $calc(%host.type + 1)

That will save a lot of elseif stuff.

The end of your init will look like this:

Code:
  if (!%host.type) { set %host.type 2 | did -c $dname 25 %host.type }
  else { did -c $dname 25 $calc(%host.type + 1) }