Pointer for current field???

I'm writing my first bash function, and I'm having a little bit of trouble getting used to the syntax. I have been told that it is very similar to Java, but I'm still not quite getting it.

The situation that I am dealing with is checking the values on input fields. There will be anywhere between two and five fields, so the code has to be able to adapt. The fields with either be a string, or a number. This is what I have so far...I am also using the match function, which I have never used before.

This function takes place within a file, which is used as a set of rules to be executed in an awk statement.

#is there a way to make a pointer for the field you are currently looking at?

function get(){
 #do bash functions take on parameters?
 #I don't know if it will be executed like get($i) or $i.get()?

if ( match( CURRENT FIELD? /�0' | [1-9][0-9]*/)
     do something
if ( match( CURRENT FIELD? /[a-z]+/)
     do something else
}

So, my question is, is there a way to have a pointer for the current field? I need to check each one, one by one, every time. I haven't been able to find this answer anywhere else, so I'm hoping someone can help me out.

Also, does the function in bash take parameters? Or would it be executed get( current field variable...???) or currentfieldvariable.get()?

I don't really need help with the "do something else" part of the code, because I know how to do it.

Have you tried:

function get(){
  echo "Inside of get <${1}>"
}
# For constant parameters:
for mEach in $(echo "abc def ghi"); do
  echo "Now calling get with ${mEach}"
  get ${mEach}
done

# For command line parameters:
for mEach in $@; do
  echo "Now calling get with ${mEach}"
  get ${mEach}
done


BASH has variable references ala ${!VARNAME}, if VARNAME is ABC will give you the value of $ABC

Setting the variable through a reference is harder though, you have to build a shell statement and feed it into eval.

It would probably help to see your code, there may be ways to do this without using references of any sort.

Functions do indeed take parameters. Parameter 1 becomes $1, parameter 2 becomes $2, etc. You can use shift to put it in a loop -- it pops off the first parameter, making $2 into $1, $3 into $2, etc.

function func
{
        while [ "$#" -gt 0 ]
        do
                echo "Parameter is $1"
                shift
        done
}

func a "b c"