Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

array name in a variable
Is it possible to put the array name in a var and use it ?

ex:
$1="array"
$1[3] = 4



--
--
I use PGP. Ask for my key if interested.
-



Report this thread to moderator Post Follow-up to this message
Old Post
Tony
09-17-04 01:10 AM


Re: array name in a variable
Hi,

In article <ci53re$5t2$1@le1.cs.unibo.it>, Tony wrote:
> Is it possible to put the array name in a var and use it ?
>
> ex:
>  $1="array"
> $1[3] = 4

with most awks it's not possible.  The AWK, mawk, gawk--all compile
the program at the beginning to an internal form and you cannot invoke
the parser later on.  But you can use shell, of course, eg:

arrname=array
awk 'BEGIN {
...
'$arrname'[3] = 4
...

HTH,
Stepan Kasal

Report this thread to moderator Post Follow-up to this message
Old Post
Stepan Kasal
09-17-04 01:10 AM


Re: array name in a variable
thank you very much

--
--
I use PGP/GPG. Ask for my key if interested.
-

"Stepan Kasal" <kasal@ucw.cz> ha scritto nel messaggio
news:slrnckdehf.un6.kasal@matsrv.math.cas.cz...
> Hi,
>
> In article <ci53re$5t2$1@le1.cs.unibo.it>, Tony wrote: 
>
> with most awks it's not possible.  The AWK, mawk, gawk--all compile
> the program at the beginning to an internal form and you cannot invoke
> the parser later on.  But you can use shell, of course, eg:
>
> arrname=array
> awk 'BEGIN {
> ...
> '$arrname'[3] = 4
> ...
>
> HTH,
> Stepan Kasal



Report this thread to moderator Post Follow-up to this message
Old Post
Tony
09-17-04 08:56 AM


Re: array name in a variable
Tony wrote:

> Is it possible to put the array name in a var and use it ?
>
> ex:
>  $1="array"
> $1[3] = 4

Use a two dimensional array where $1 is the first element.

$1="array";
x[$1,3]=4;

-- glen



Report this thread to moderator Post Follow-up to this message
Old Post
glen herrmannsfeldt
09-30-04 07:55 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

AWK archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:12 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.