am beginner in Tcl/tk, facing problem in accessing array in procedure
below is my problem statement
proc myproc {args} {
set aaa ""
set bbb ""
set ccc ""
foreach "field value" $args {
set $field $value
}
# assigning input args values to an array a
set a(3:0) $aaa
set a(6:4) $bbb
set a(25:7) $ccc
#do some computation on input arguments may be addition
#
#
#
# now the result am trying to fetch into another array b
set $b(word0) $x
set $b(word1) $y
set $b(word2) $z
set $b(word3) $u
return [array get b]
}
now i need to pass arguments to myproc and return array i need to access.
set args_1 "g 1 h 4 k 6"
i tried the below syntax it was throwing me error.
array set a [myproc[array get $args_1]]
can somebody help me in solving this issue
trying to give string as input for procedure myproc
and later trying to do some computation with that input values.
later after all computation got set of string values, which are assigned to array as below
set $b(word0) $x
set $b(word1) $y
set $b(word2) $z
set $b(word3) $u
want to send this array b as return.
example:
proc myproc {} {
set $b(word0) $x
set $b(word1) $y
set $b(word2) $z
set $b(word3) $u
return [array get b]
}
i have tried to access array b as below
array set a [myproc[array get b]]
it worked :) was able to creat new array in calling function.
but, need to pass string arguments to myproc and get return as array