[R] tclVar Question

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Fri Jan 10 01:46:03 CET 2003


"Jason Fisher" <stormplot at hotmail.com> writes:

> Hi All...
> 
> In an attempt to read data from a file and feed it into a tcltk entry
> box, I've run into difficulties.  The following hopefully describes my
> dilemma:
> 
> tclvalue(x.var) <- 5
> Works fine.
> 
> tclvalue("x.var") <- 5
> Does not work.  [Error: Target of assignment expands to non-language object]
> 
> tclvalue(eval(parse(text="x.var"))) <- 5
> Also, does not work.
> 
> Any ideas on how to get this to work?

Um, getting what to work? I see two interpretations: 

If you want to assign to a variable with a specified Tcl name, you
bump into the issue that the semantics of foo(x)<-whatever will try to
modify x and that won't do if x is a literal constant, so

"tclvalue<-"("x.var", 5) 
works and so does
z <- "x.var"; tclvalue(z) <- 5

or just tkcmd("set","x.var",5) and be gone with it...

On the other hand, if you have the name of a tclVar object as a
character string and you want to modify the object, then the recipe
would be something along the lines of

eval(substitute(tclvalue(foo) <- 5, list(foo=as.name("x.var"))))

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list