Then within filename.awk I want to access array1[n]. However, awk mistakes array1[2] (the third element of the array) for the input file. How I can pass awk this array?
It also appears that awk scripts can't understand ":-" or ${#var}. Is this correct?
awk is entirely its own programming language with its own variables that have nothing to do with the shell's. -v arguments are where shell variables and awk variables meet, to get them into awk you pass them in there as raw text.