Does anyone know of an inexpensive mechanism for creating variable names 'on
the fly'? That is, do you know of any way to use a $variable on the lhs of
an assignment? The intent is to create a vector of values. The only solution
I have come up with seems a bit expensive, although I haven't done any
measurements. That method is to use an INCLUDERC inside my recursing rc as
follows:
# increment item count
:0
* $ $N^0
* 1^0
{ N=$= }
# later ...
# add items
:0 w i c
| echo "HELO$N=$HELO IP$N=$IP NAME$N=$NAME" > $ABSPATH/expandit.rc
INCLUDERC=$ABSPATH/expandit.rc
Back in the main rc, individual items can be extracted, up to the value of
N, by fixed variables (NAME1, IP3, ...). This is used inside a recursive
includerc which walks down received headers, but there certainly can be
other uses.
What I am actually using now is a bit simpler. I just append a flag
character and the next value to a fixed variable name. It works fine,
although extracting values is a bit clumsy.
--
Rik Kabel Old enough to be an adult
rik(_at_)netcom(_dot_)com