Le 19/11/2024 à 14:41, J C Nash a écrit :
In answer to my own posting about this, I found the following partially
answers what I need.
The task is to display a file (in my case a pdf, for which 'xdisp' contains
the string for the command to do this. See below for the reason this is a
variable. The displayed file has information I will need to possibly enter
into other program structures and which may be in the form of pixels rather
than text or numbers. Later, I wish to close the display when the need
is past.
Clearly, that step could be left to the user, but I believe in decluttering
the screen as much as I can.
cmd<-cmd <- paste0(xdisp," ",xdocfn," &") # add & to keep running and
return??
system(cmd)
pidcmd<-paste0("pgrep -f '",cmd,"'")
spid<-system(pidcmd, intern=TRUE) # gets spid, but stays running
# For some reason increased by 1
spid<-as.integer(spid)-1
Later on I can close the display with
# Kill the display of the statement now.
tmp<-readline("Kill the bill display process now")
kcmd<-paste0("kill -9 ",spid)
Clearly I'm on a Linux system (Mint 22 Wilma) I've not considered how
I'd do this
in Windows, but would welcome suggestions as I believe cross-platform
solutions
widen the utility of any software. I also looked at the CRAN package ps,
and found
there are ways to use some of its tools. They may, in fact, be more
system-neutral,
so are still on my radar for consideration.
My posting asked also if the display could be controlled as to position
and size.
I have not yet found how to do that, but have found choice of the pdf
display
program a partial help. I am currently setting xdisp to xpdf in an "ini"
file,
for which the CRAN package ini is most helpful.
For information, I put below a solution to an Rstudio matter that arose.
Comments and discussion welcome.
Best,
John Nash
PS. In building this code in Rstudio and using browseURL(file) to open
the display,
I got a warning error about "signal 10". This can be overcome by using
browseURL(file, browser="xdg-open"). However, "file" must be either a
simple
filename of a file in the current directory, or a fully qualified path. Use
of the shortcut "~/" for the home directory fails.
may be path.exapnd()?
> path.expand("~/tmp/my.pdf")
[1] "/home/sokol/tmp/my.pdf"
This issue does not
arise
for R in a terminal.
______________________________________________
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel
______________________________________________
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel