I see you turned it to an array and then used for each.
substr() would have got you there without the need for that and with ~100 strikes shorter...

anyways, your code fixed and shorther, 489 -> 475
 Code:
function a($, optional $k,$b,$x,$z)
;   if asc($)=32 or asc($)=9
if not $k
      $k = right($,1)
      $ = Replace($,$k,0)
      $x = iif($k='	',' ','	')
      $ = Replace($,$x,1)+$k
      for $x=0 to len($)/8
         $b=$b+' '+substr($,$x*8+1,8)
      next
      for each $x in Split($b)
         $b = 128
         $=0
         for $z=1 to 8
            $ = $+$b*substr($x,$z,1)
            $b = $b/2
         next
         $a = $a+Chr($)
      next
   else
      $b = asc($)
      for $x=1 to len($)-1
         $b=''+$b+' '+asc(right($,-$x))
      next
      for each $x in Split($b)
         $ = 128
         for $z=1 to 8
            if $<=$x
               $a = $a+"1"
               $x = 0+$x-$
            else
               $a = $a+"0"
            endif
            $ = $/2
         next
      next
      $a = Replace($a,0,$k)
      $ = iif($k="	"," ","	")
      $a = Replace($a,1,$)+$k
endfunction
_________________________
!

download KiXnet