[R] curious mistake in tkradiobutton

solares@unsl.edu.ar solares at unsl.edu.ar
Thu Oct 9 17:42:21 CEST 2003


Hello, the following code produces an error when executing it, it is a code 
that produces 6 checkbutton that at 
the beginning are empty, when selecting the first checkbox he says that  
doesn't know the second 
variable tcl, he say: 

[1] "1"
Error in structure(.External("dotTcl", ..., PACKAGE = "tcltk"), class 
= "tclObj") : 
        [tcl] can't read "::RTcl2": no such variable.

when six variables tcl has been created in the array b and they exist:

> b
[1] "::RTcl1" "::RTcl2" "::RTcl3" "::RTcl4" "::RTcl5" "::RTcl6"

the script is(I'm use R 1.7.1 for win):

library(tcltk)
tt<-tktoplevel()
f<-tkframe(tt)
tkpack(f)
j<-6
nbre<-c("c1","c2","c3","c4","c5","c6")
b<-c()
i<-1
 while (i<=j){
  aux<-paste("b",i,sep="")
  aux<-tclVar(init=0)
  b<-c(b,as.character(aux))
  tclvalue(b[i])<-0
  i<-i+1
 }
 i<-1
 while (i<=j){
 t<-tkcheckbutton(f,text=nbre[i],variable=eval(b
[i]),relief="raised",command=function()ver())
 tkpack(t)
 i<-i+1
 }
 
 ver<-function(){
 k<-1
 while (k<=j){
  print(tclvalue(b[k]))
  k<-k+1
  }
  }

 any help will be welcome. Thank you Ruben




More information about the R-help mailing list