[rkward-cvs] SF.net SVN: rkward:[4173] trunk/rkward/rkward/rbackend/rpackages/rkward/R/ internal.R
m-eik at users.sourceforge.net
m-eik at users.sourceforge.net
Sun Mar 11 21:36:59 UTC 2012
Revision: 4173
http://rkward.svn.sourceforge.net/rkward/?rev=4173&view=rev
Author: m-eik
Date: 2012-03-11 21:36:59 +0000 (Sun, 11 Mar 2012)
Log Message:
-----------
enabling q() to work if package rkward wasn't loaded in an RKWard session
Modified Paths:
--------------
trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R
Modified: trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R 2012-03-11 21:11:01 UTC (rev 4172)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R 2012-03-11 21:36:59 UTC (rev 4173)
@@ -165,10 +165,25 @@
}
}
+# this function shall test if the rkward package was loaded in a running RKWard session
+.rk.inside.rkward.session <- function(warn = FALSE){
+ inside.rkward <- is.loaded("rk.do.generic.request")
+ if(isTRUE(warn) & !isTRUE(inside.rkward)){
+ warning("You've loaded the package 'rkward', but RKWard doesn't appear to be running. If this causes trouble, try detach(\"package:rkward\").",
+ call. = FALSE)
+ }
+ return(inside.rkward)
+}
+
# overriding q, to ask via GUI instead. Arguments are not interpreted.
"q" <- function (save = "default", status = 0, runLast = TRUE, ...) {
- res <- .rk.do.plain.call ("quit")
- if (length (res) && (res == "FALSE")) stop ("Quitting was cancelled")
+ # test if this is running in RKWard, otherwise pass through to the actual q()
+ if (isTRUE(.rk.inside.rkward.session())){
+ res <- .rk.do.plain.call ("quit")
+ if (length (res) && (res == "FALSE")) stop ("Quitting was cancelled")
+ } else {
+ base:::q(save = save, status = status, runLast = runLast)
+ }
}
"quit" <- function (save = "default", status = 0, runLast = TRUE, ...) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the rkward-tracker
mailing list