Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to bring the choose.file() dialog to the foreground

I'm using the function choose.dir() in a script that is run with rscript.exe under Windows XP. The problem is that the directory choosing dialog does not pop up as a top-level window. How can I bring the dialogue to the foreground?

In the meantime, I solved my problem by using visual basic script. Of course, this only works with windows:

tf <- tempfile(fileext = '.vbs')
cat('Set folder = CreateObject("Shell.Application") _
        .BrowseForFolder(0, "Please choose a folder" _
       , &H0001, 17)
       Wscript.Echo folder.Self.Path
', file = tf)
tail(shell(paste('Cscript', tf), intern = T), 1)
like image 274
zara77 Avatar asked Nov 14 '22 18:11

zara77


1 Answers

After searching the rhelp archives it appears the answer is that you can't use choose.dir and file.choose in a non-interactive session. You might be able to do something similar, since list.files, file.info, file.access and files can be used to gather information, you can display this by writing to a graphics device and executing a system() call to get it displayed, and readLines can be used to get user input.

like image 91
IRTFM Avatar answered Nov 16 '22 17:11

IRTFM