This function will pop up the window, get the number, and return it:

tmpfun <- function() {
        tt <- tktoplevel()
        Name <- tclVar("")
        entry.Name <-tkentry(tt,width="20",textvariable=Name)
        tkgrid(tklabel(tt,text="Please enter site number."))
        tkgrid(entry.Name)
        OnOK <- function()
        
        {
                NameVal <- tclvalue(Name)
                use.this=NameVal
                tkdestroy(tt)
        }

        OK.but <-tkbutton(tt,text="   OK   ",command=OnOK)
        tkbind(entry.Name, "<Return>",OnOK)
        tkgrid(OK.but)

        tkwait.window(tt)

        return(as.numeric(tclvalue(Name)))
}

Run it like:

> tmp <- tmpfun()

And after clicking on OK tmp will have the number in it.

The database experts will need to tell you how to include that into your query 
(either using the above function, or putting the query in place of the return 
and returning the result).

Hope this helps,




-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -----Original Message-----
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of RagingJim
> Sent: Tuesday, February 16, 2010 5:31 PM
> To: r-help@r-project.org
> Subject: Re: [R] Using text put into a dialog box
> 
> 
> Thanks Greg, the problem is I have no idea how to return and use what I
> have
> typed into the pop up. Add to that the complication that with this
> query
> 
> x<-sqlQuery(conn, "select to_char(lsd,'yyyy-mm') as yr,ttl_mo_prcp from
> mo_rains where stn_num=23090")
> 
> if I put anything other than a number into stn_num=... then it does not
> run.
> eg if I just do sn=23090 and then use that in the query
> 
> sqlQuery(conn, "select to_char(lsd,'yyyy-mm') as yr,ttl_mo_prcp from
> mo_rains where stn_num=sn")
> 
> I get the following error.
> 
> [1] "[RODBC] ERROR: Could not SQLExecDirect"
> [2] "42S22 904 [Oracle][ODBC][Ora]ORA-00904: \"SN\": invalid
> identifier\n"
> 
> So my question is in two parts. Firstly, how do I return the number
> written
> in the popup, and then secondly how do I actually put it into the
> query?
> 
> Thanks again
> --
> View this message in context: http://n4.nabble.com/Using-text-put-into-
> a-dialog-box-tp1555761p1558124.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> 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.

______________________________________________
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.

Reply via email to