# NOT RUN {
## source a file using a handler
sourceFile <- function() gfile("Select a file",type="open", handler =
function(h,...) source(h$file))
## source an R file using fact that dialog is modal
source(gfile(filter=c("R files"="R")))
## apply a generic action to the file
countLines <- function(filename) print(length(readLines(filename)))
chooseFile <- function() gfile("Select a file",type="open",
action="countLines", handler = function(h,...) do.call(h$action,list(h$file)))
# }
Run the code above in your browser using DataLab