Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 31 Aug 1997 09:31:09 -0700 (MST)
From:      Charles Mott <cmott@snake.srv.net>
To:        Brian Somers <brian@awfulhak.org>
Cc:        questions@FreeBSD.ORG
Subject:   Re: ppp and internal modem 
Message-ID:  <Pine.BSF.3.96.970831092711.21019A-100000@darkstar.home>
In-Reply-To: <199708311139.MAA01152@awfulhak.demon.co.uk>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 31 Aug 1997, Brian Somers wrote:
> [.....]
> > I was just doing some scripting in awk, and the array indices
> > seemed to start with 1 and not 0, and this language was invented by the
> > same person who started C.
> > 
> 
> Hmmm, from the awk man page:
> 
>        ARGV        Array  of command line arguments. The array is
>                    indexed from  0  to  ARGC  -  1.   Dynamically
>                    changing  the contents of ARGV can control the
>                    files used for data.
> [.....]
>        array  x which is indexed by the string "A\034B\034C". All
>        arrays in AWK are associative, i.e. indexed by string val-
>        ues.
> 
> I can't claim to know much (practically) about arrays in awk - when 
> you get to that level, a C program is really in order ;-)  But from 
> the docs, it seems that arrays are sparce and can effectively begin 
> with anything.

You are entirely correct from a technical point of view and I should have
been a little more careful with my wording.  The first character in a
string is denoted as 1 in the substr(), and when an array is created by
split(), the first token is pointed to by the [1] index.  This was a
little counter-intuitive to me at first.

However, arrays in their most general form in awk are associative and
don't really have anything to do with numeric indexes.

Charles Mott




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.96.970831092711.21019A-100000>