Code Comments
Programming Forum and web based access to our favorite programming groups.On 3=BF=F919=C0=CF, =BF=C0=C0=FC4=BD=C356=BA=D0, mjc <mjco...@acm.org> wrote = : > On Mar 17, 9:30 pm, iaminsik <iamin...@gmail.com> wrote: > > > > > acea.null.org> wrote: > ). > ---- ---- > > > > > > > > tr \ tr \ > > > > > > > > > > > > > > > > > > > One thing I noticed is that there are no local variables in your > subroutines. I've never heard of declare variables as 'local' in awk. > > I would declare then (in the "function" statement) so there would be, > for example, no chance of "i" in one routine conflicting with "i" in > another.- =B5=FB=BF=C2 =C5=D8=BD=BA=C6=AE =BC=FB=B1=E2=B1=E2 - Can you show an example? > > - =B5=FB=BF=C2 =C5=D8=BD=BA=C6=AE =BA=B8=B1=E2 - Regards. Remi.
Post Follow-up to this messageIn article <5de8b96e-75af-4e74-9c9f-46d9c5dc69d8@u10g2000prn.googlegroups.co
m>,
iaminsik <iaminsik@gmail.com> wrote:
...
>I've never heard of declare variables as 'local' in awk.
TAWK has true local variables, which is very nice, but in "standard"
AWK it is done via a (widely accepted and practiced) kludge. See below.
>
>Can you show an example?
The idea is that you declare your funciton like this:
function foo(arg1,arg2, tmp1,tmp2,tmp3) {}
And then call it with only 2 args. The additional args get initalized
to "" (as if they had been passed by the caller as ""), and act like
local variables in the function.
It is also conventional to separate the "real" args from the fake args,
with whitespace, as I have done above.
Post Follow-up to this messageOn 3=EC=9B=9419=EC=9D=BC, =EC=98=A4=ED=9B=8411=EC=8B=9C31=EB=B6=84
, gaze...@
=
xmission.xmission.com (Kenny McCormack)
wrote:
> In article <5de8b96e-75af-4e74-9c9f-46d9c5dc6...@u10g2000prn.googlegroups.=[/color
]
com>,iaminsik =C2=A0<iamin...@gmail.com> wrote:
>
> ...
>
>
> TAWK has true local variables, which is very nice, but in "standard"
> AWK it is done via a (widely accepted and practiced) kludge. =C2=A0See bel=[/color
]
ow.
>
>
>
=C2=BC=C3=BB=C2=B1=C3=A2=C2=B1=C3=A2 -
>
>
> The idea is that you declare your funciton like this:
>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 function foo(arg1,arg2, =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 tmp1,tmp2,tmp3) {}
>
> And then call it with only 2 args. =C2=A0The additional args get initalize=[/color
]
d
> to "" (as if they had been passed by the caller as ""), and act like
> local variables in the function.
>
> It is also conventional to separate the "real" args from the fake args,
> with whitespace, as I have done above.
Sorry for this late reply. :)
It's a nice trick.
I'll try!
Best Regards.
Remi.
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.