[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] zerofile

From: Aharon Robbins
Subject: Re: [bug-gawk] zerofile
Date: Mon, 20 May 2013 23:10:42 +0300
User-agent: Heirloom mailx 12.5 6/20/10


> Date: Fri, 17 May 2013 12:30:49 +0100
> From: david ward <address@hidden>
> To: bug-gawk <address@hidden>
> Subject: Re: [bug-gawk] zerofile
> correction:
> zerofilef.awk should be
> #!/usr/bin/gawk -f
> function zerofile(ARGV[Argind, Argind )
> {
>    print ARGIND,Argind, ARGV[Argind]
> }
> Output is
> > gawk -f zerofile.awk  -f zerofilef.awk  --source '{ print }'empty
> nonempty empty2
> gawk: zerofilef.awk:2: function zerofile(ARGV[Argind, Argind )
> gawk: zerofilef.awk:2:                       ^ syntax error
> gawk: zerofilef.awk:2: error: function `zerofile': can't use special
> variable `ARGV' as a function parameter
> This my last email on this function; I don't want to become a nuisance
> rather than a help

Gawk is telling you what is wrong.  You have made three errors here.

1. You cannot use ARGV as the name of a function parameter, since it is
   a reserved variable.
2. You are trying to use an array element as a parameter, but that is
   not the correct syntax, you just give parameter names, unadorned
3. Even as an element, it's not right since you don't have the close bracket.

You want something like this:

        function zerofile(Argind)
           print ARGIND, Argind, ARGV[Argind]



reply via email to

[Prev in Thread] Current Thread [Next in Thread]