Second parameter is not recognized

Hey I have a problem with my script.
I writing a script which can depend whether you want to make a file or a directory.
I only give the code where you can find the problem.
My loop doesn't stop and I don't know why and
when i echo my second parameter , he echoes nothing :s

Thnx

function files()
{
 local var=$2;
 for (( i=1;i -le $var;i++))               
 do
  touch test$i /home/arian/Bureaublad/scripts
  echo $i
done
}

case $1 in
  "-f")files $2;;
    *) echo "foutieve ingave ! optie + aantal bestanden/mappen";;
esac

Inside your function, $n refer to the n-th passed argument to the function, and NOT to the n-th passed argument of the script

Your function has 1 argument so you want to refer to the passed argument :

local var=$1