It is interesting that your Spanish awk code is very different from your English awk code, neither of them defines any function, both of them have a "}" with no matching "{", and the Spanish version has a "(" with no matching ")".
The way to define a function in awk is to use:
function function_name([parameter, ...]) { statements }
You didn't have the word function (which is required in a function definition) anywhere in your awk scripts.
And, when you invoke a user-defined function, there can't be any space between function_name and the following open parenthesis (which you have in the English version of your script). The English version of your script also has lots of other extra spaces that shouldn't be there (between "$" and the field number following it, between an array name and the following "[".
You can define a function in an awk script anywhere you can have a pattern{action} pair (which includes before or after a BEGIN{action} or before or after an END{action} . A function definition cannot appear as part of the action in a BEGIN or ENDpattern{action} pair.
PS. If you intend to write an awk script on a Solaris system (guessing from your login name), use /usr/xpg4/bin/awk , /usr/xpg6/bin/awk , or nawk instead of /bin/awk or /usr/bin/awk .
You apologize to me, I will follow the rules of that foro.
I undestand, It isn't possible define a user-defined function within the END block, thank you for helping.
I started using OpenSolaris in 2009, Now I use Kubuntu and OpenSuse.