I keep messing that up, sorry...
Code:
alias unban {
  if ( !$chan(#).ibl ) { mode # -b $ial($1) | return }
  if ( $ial($$1) !isban # ) { return }
  var %x = $ibl(#,0), %b, %a = %ial($1)
  while (%x) { if ($ibl(#,%x) iswm %a) { var %b = %b $ibl(#,%x) } | dec %x }
  if ( %b ) { mode # $+(-,$str(b,$numtok(%b,32))) %b }
}

Try that.. I forgot the # in that line you had a problem with.
grin
The purpose of that line is to cut down on script usage. Why search the ibl if it's there are no matching bans?