Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

arrays of arrays?

259 views
Skip to first unread message

Peter M. Jansson

unread,
Jul 15, 1996, 3:00:00 AM7/15/96
to

How can I set up an array so that its value can be used by a procedure as
another array? I'm trying to handle a parsing and substitution job, and I
want to build up the list of variables where variables are named
thing1.thing2. I want to create an array in which the element at index
thing1 is used to access another array in which element thing2 has the
value I want.

Thanks,
Pete.

Flemming Madsen

unread,
Jul 18, 1996, 3:00:00 AM7/18/96
to f...@cci.dk
There is no such thing as arrays of arrays in tcl.
There is basically threee ways to go:

1) Encode it in the array indexes like $BigArray($thing1/$thing2), but
then
you mmust traverse thing1 by globbing with $thing1/* in the array
keys of
BigArray (returned with [array names BigArray]

2) Use an array of lists like [lindex $BigArray($thing1) $thing2] but
then
$thing 2 must be numeric

3) Use an array of keyed lists (requires TclX) like
[keylget BigArray($thing1) $thing2]

In the latter two cases the number of $thing2 entries must be relatively
small to preserve performance since the whole list is potentially
traversed to obtain the entry

--


Flemming Madsen CCI-europe
----------------- Oester Parkvej 9
Basic Development DK-8270 Hoejbjerg
Aarhus - Denmark
Email: f...@cci.dk Phone: +45 86295588


0 new messages