$0 not giving script name

Why does $0 return the word usage rather than the script name when used in a function?

Baffeled on this one, any help appreciated.

usage()
{
  echo "$0 -cs <number of batches>\n"
  echo "$0 -c 4"
  echo "$0 -s 4"
# echo "-c = Create"
# echo "-s = Submit\n"

  exit 1
}



$ Create_batch.ksh
usage -cs <number of batches>

usage -c 4
usage -s 4

Because $0 inside a function is not the same as outside the function. Outside it is the name of the script, as you noticed and inside the function it is the function's positional parameters.
Besides that I can't see where you call this function at all so you might want to write something like:

#!/bin/bash

usage()
{
  scriptname=$1
  # $1 is the 1st parameter handed over by calling the function (down there the $0 in this case), which is the name of the script
  echo "$scriptname -cs <number of batches>\n"

  exit 1
}

usage $0

exit 0