Function doesn't work

Hello, and here's my problem:

I can't get my function to do what I want. When I call my function  get\_from\_A\_to_F I give it an argument $remainder. I want my function to  substitute a number higher than 9 to a specific letter. If the argument  is equal to 10 than it should change it to "A". However it still leaves  it as a 10. What am I doing wrong here?
#!/bin/sh

get_from_A_to_F() 
{   
    case $1 in
        10)  $1="A"
        ;;
        11)  $1="B"
        ;;
        12)  $1="C"
        ;;
        13)  $1="D"
        ;;
        14)  $1="E"
        ;;
        15)  $1="F"    
        ;; 
        [0-9]) $1=$1
        ;;  
    esac
    echo $1
}

read number
string=""
index=`expr index $number "."`
if [ $index -eq 0 ]
then
    integer=$number
    fraction=0
else
    integer=`expr substr $number 1 $(expr $index - 1)`
    fraction=`expr "$number - $integer" | bc`
fi
result=$integer
while [ $result -ne 0 ] 
do
    remainder=`expr $result % 16`
    get_from_A_to_F $remainder
    result=`expr $result / 16`
    string=$remainder$string
    #echo $string
done

Did you try enclosing function's argument in double quote ?

get_from_A_to_F "$remainder"

Yes, still doesn't work, any other ideas

Let's say the number is 634. In that case the output of this script is:

634
test: 43: 10=A: not found
10
test: 43: 7=7: not found
7
test: 43: 2=2: not found
2

Note : when you are inside your function, "$1" refers to the first argument passed to your function (and not the first argument given to your shell script).

Instead of your function, you could go with :

echo "ibase=10;obase=16;$remainder" | bc

You can define remainder as a variable outside the function:-

typeset remainder

And use the variable directly instead of $1

case $remainder

I hope it helps.

I tweaked your script a bit. Is this the output you're looking for:

./testme.sh
634
A
10
7
7
2
2

You should by the way read more about handling variable locally or globally.
Read this link and pay attention to 6.5.1 section

Regarding your hex conversion:

$ remainder=634
$ echo "ibase=10;obase=16;$remainder" | bc
27A

Not exactly, but I see you managed to make it print the substituted value.

My desirable output is(if number read is 634):

634
A
7
2

$ echo "ibase=10;obase=16;$remainder" | bc | fold -w 1 | tac
A
7
2

You may need to replace tac with tail -r depending on your OS

echo "ibase=10;obase=16;$remainder" | bc | fold -w 1 | tail -r