Mine down to 151

 Code:
function a($,$p)
  dim $i,$t
  for $i=9 to 1 step -1
    while instr($,$i) & $t=0
      $t=$p=0 & $i=$
      $p=iif($p=0,($^)/2,$p-1)
      $a=$a+1*$/$i
      $=right($,-2) + iif($i>$,_ + 1*$,"")
    ;loop 
  ;next 
endfunction