Re: number of files
[email protected] Thu, 7 Apr 2005 09:06:07 -0400
| Newsgroups | gmane.comp.web.wiki.awkiawki.user |
|---|---|
| Message-ID | <[email protected]> |
On Apr 6, 2005, at 2:00 PM, Atte Andr=E9 Jensen wrote:
> I'm not really an awk-hacker, but it seems that awk doesn't support=20
> multidimentionel arrays.
>
> I'm working on another appreach, also with a definition file for each=20=
> language. I'll get back when I'm though.
AWK handles multidimensional arrays just fine. Just use multiiple keys=20=
separated by commas. What it doesn't do is allow for an array to be=20
copied to another array with a simple assignment operator. I.e.:
a[1] =3D 5
a[2] =3D 7
b =3D a
Doesn't work. Instead, one must write:
for(i in a) b[i] =3D a[i]
Also, this doesn't work:
for( i,j in some_array) ...
Instead, you have to write:
for( m in some_array ) {
split(m, arr, SUBSEP)
i =3D arr[1]
j =3D arr[2]
...
}
So, for the language example, copying the language specific strings=20
into the localized space would look like:
messages["EN","special_history","version"]=3D"version"
messages["EN","special_history","date"]=3D"date"
messages["EN","special_history","comment"]=3D"comment"
messages["EN","special_history","view"]=3D"view version"
messages["EN","special_history","edit"]=3D"edit version"
messages["EN","special_history","diff"]=3D"diff to current"
for( i in messages) {
split(i,multi,SUBSEP)
l =3D multi[1]
m =3D multi[2]
n =3D multi[3]
if( l =3D=3D language )
localized_messages[m,n] =3D messages[l,m,n]
}
Overall, AWK is such an elegant language, I don't know why its=20
inventors didn't include ways to handle multidimensional arrays without=20=
having to know the underlying nuts and bolts. I've corresponded with=20
the maintainer of GAWK. He doesn't want to add any new syntactical=20
elements to the language.
> Hi
>
> Are there any reason the code in parser.awk and special_parser.awk=20
> aren't placed in awki.cgi? I think it would remove some clutter and=20
> make installation easier if there was only one file needed. The=20
> awki.conf + the language files under construction, would be=20
> optional...
>
> Any thoughts?
>
I have a version of awkiawki with a number of modifications, including=20=
having the parser in awki.cgi. But, I wouldn't do it that way, again.=20
Putting the parsers in separate programs keeps the CGI program smaller=20=
and simpler. What makes it complicated is the fact that sometimes it=20
parses text generated within awki.cgi, and, sometimes, it parses=20
external files. So, it's much simpler to "print" to the parser in one=20
case and feed the parser a file from the command line in the other=20
case.
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click