Duncan Murdoch wrote: > On 1/15/2009 10:18 AM, davide.massi...@unipd.it wrote: >> Dear R-helpers, >> I have a problem with the tcl "after" instruction. When I send: >> >>> library(tcltk) >> Loading Tcl/Tk interface ... done >> >>> tcl("after",1000,cat("try tcl after\n")) >> try tcl after >> <Tcl> >> >> the tcl command works fine. Similarly, the tcl command: >> >>> tcl("after",1000,plot(rnorm(100))) >> <Tcl> >> >> works fine. But, if I send the command: >> >>> tcl("after",1000,10^2) >> <Tcl> after#0 >> >> appears a popup window which reports: >> >> Error: invalid command name “100” >> >> Why? > > The value of cat("something") is NULL, the value of plot(something) is > NULL, but the value of 10^2 is 100. You're trying to execute no Tcl > command in the first two cases, but you're trying to execute the command > "100" in the last, and that's not a legal Tcl command.
Yes. Notice also that the argument is intended to be something to do *after* the period of time has elapsed, and as written, it happens immediately. You can use an R expression there, but it needs to be an unevaluated call, usually created by quote() or expression(). > tcl("after",5000,quote(cat("try tcl after\n"))) ; for (i in 1:10){print(i);Sys.sleep(1)} <Tcl> after#4 [1] 1 [1] 2 [1] 3 [1] 4 [1] 5 try tcl after [1] 6 [1] 7 [1] 8 [1] 9 [1] 10 -- O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalga...@biostat.ku.dk) FAX: (+45) 35327907 ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.