"U.V. Ravindra" wrote:
>
> The final for-loop in the script I supplied to Roland is obviously
> mis-written.
> It should be:
>
> typeset -i idx=0
>
> for arg in ${argtype[*]}; do
> print "${argtype[$idx]} \t ${argname[$idx]} \t ${argvalue[$idx]}"
> ((idx = idx + 1))
> done
Erm... shouldn't this for-loop iterate over each array element ? If
"yes" the loop should AFAIK look like this:
-- snip --
integer idx
for (( idx=0 ; idx < ${!argty...@]} ; idx++ )) ; do
printf "%s \t %s \t %s\n" \
"${argtype[$idx]}" \
"${argname[$idx]}" \
"${argvalue[$idx]}"
done
-- snip --
Note that I replace the "print" with "printf" and moved the varable
expansions to printf arguments to avoid that any '\'-charatcer is
interpreted by "print"/"printf" itself.
BTW: In ksh93 you do not need three seperate arrays - you can use
compound variables, e.g.
-- snip --
typeset -a arg
arg[0].type="my type"
arg[0].name="my name"
arg[0].value"a value"
-- snip --
... an identical (but usually "sleeker" syntax is:
-- snip --
typeset -a arg
arg[0]=(
type="my type"
name="my name"
value"a value"
)
-- snip --
... and in loops you may use a "nameref" (variable name reference) to
handle the repeated usage of "arg[0]" (or arg[idx]):
-- snip --
typeset -a arg
nameref node=arg[0]
node.type="my type"
node.name="my name"
node.value"a value"
-- snip --
or
-- snip --
typeset -a arg
nameref node=arg[0]
node=(
type="my type"
name="my name"
value"a value"
)
-- snip --
----
Bye,
Roland
--
__ . . __
(o.\ \/ /.o) roland.mainz at nrubsig.org
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL <currently fluctuating>
(;O/ \/ \O;)