"fixing" Jochen's code seems too hard for me, so, wen't for Howards instead.

237 by switching $z and $ and then taking out the need for the array stuff:
 Code:
function a($s, optional $k,$z,$c,$e,$p,$)
;  $=1,128,64,32,16,8,4,2,1
  For $c=1 To ($s^)
    $=$+($=)*128
    $p=substr($s,$c,1)
    if $k
      ;Encode
      For $z=1 to 8
        $a=$a+iif(asc($p) & $, iif($k=" ","	"," "), $k)
	$=$/2
      Next
    else
      ;Decode
;      $z=$c mod 8
      $e=$*(right($s,1)<>$p)+$e
      $=$/2
      if $=0
;      if $z=0
        $a=$a+chr($e)
        $e=0
      endif
    endif
  Next
  $a=$a+$k
endfunction
_________________________
!

download KiXnet