For letter to number, you could have just taken the ascii value of the lowercase letter and subtracted 96 (since 97 is a)
$calc($asc($lower(L)) - 96)
Replace L with whatever letter of course.
And vice-versa by using $chr of whatever number plus 96.
$chr($calc(n+96))
Replace n with whatever number