Skip to content

accessing tcl variables within R and tcl

3 messages · Adrian Waddell, Gabor Grothendieck, Peter Dalgaard

#
Dear R users,

I have some troubles with dealing with tclObj objects. I try to explain
it with a toy example:

Say I define the following tcl procedure which just prints out each list
element

library(tcltk)
.Tcl('proc test {myList} {
    foreach i $myList {
      puts stdout  $i
    }
}')

and I call it with:
Now say I define a tcl variable first:
However
Why not? In fact, how do get the name of the "a" list in tcl (something
like RTcl...) so I could use it as follows
Loops are much quicker in tcl than in R, hence I try to do some
computations in tcl and not via wrapper function in R. I therefore need
a way to easily access tcl variables from within R and tcl.

Thanks for any help,

Adrian Waddell
#
On Thu, Aug 12, 2010 at 2:14 PM, Adrian Waddell <ml_a at waddell.ch> wrote:
Try this:

tcl("test", tclvalue(a))
#
Adrian Waddell wrote:
Ow, that's been a while... However

tcl('test', tclvalue(a))

seems to do the trick, as does

tcl('test', tclObj(a))

The latter presumably being preferable, since it avoids conversion to
and from an R object.

If I remember these matters correctly, you are seeing the difference
between "set RTcl1" and "test $RTcl1".