hmm...
can't test this but this one should be 2 strokes smaller:
Code:

function a($)
if $ = 0 + $
$a=right($,1)
$a = "" + abs(left($,~)) + chr(iif($a,64+9*(0>$))+$a,123+2*(0>$))
else
$a = asc(right($,1))-64
$a = $a - $a*($a>18)
$ = 0 + (left($,~)+ ($a - 9*($a>9)))
$a = $ - 2*$*($a>9 & $a<>59)
endfunction

a(1234) ?
a("123D") ?
a(-1234) ?
a("123M") ?

get $