Skip to content

Commit

Permalink
updated matlabr
Browse files Browse the repository at this point in the history
  • Loading branch information
muschellij2 committed Nov 2, 2017
1 parent 1682fe6 commit 1a130c3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
@@ -1,7 +1,7 @@
Package: matlabr
Type: Package
Title: An Interface for MATLAB using System Calls
Version: 1.4.3
Version: 1.5.0
Date: 2017-10-10
Authors@R: person(given = "John",
family = "Muschelli",
Expand Down
16 changes: 13 additions & 3 deletions R/matlab_script.R
Expand Up @@ -8,6 +8,8 @@
#' @param desktop Should desktop be active for MATLAB?
#' @param splash Should splash be active for MATLAB?
#' @param display Should display be active for MATLAB?
#' @param wait Should R wait for the command to finish. Both
#' passed to \code{\link{system}} and adds the \code{-wait} flag.
#' @export
#' @return Character of command for matlab
#' @examples
Expand All @@ -18,7 +20,8 @@ get_matlab = function(
try_defaults = TRUE,
desktop = FALSE,
splash = FALSE,
display = FALSE){
display = FALSE,
wait = TRUE){
# find.matlab <- system("which matlab", ignore.stdout=TRUE)
mat = paste0(
"matlab",
Expand All @@ -35,8 +38,13 @@ get_matlab = function(
desktop = myfunc(desktop, "desktop")
splash = myfunc(splash, "splash")
display = myfunc(display, "display")
wait = ifelse(
.Platform$OS.type %in% "windows",
ifelse(wait, "-wait", ""),
"")

matcmd <- paste0(mat, " ",
wait, " ",
desktop, " ",
splash, " ",
display, " -r ")
Expand Down Expand Up @@ -110,12 +118,14 @@ run_matlab_script = function(
desktop = FALSE,
splash = FALSE,
display = FALSE,
wait = TRUE,
...){
stopifnot(file.exists(fname))
matcmd = get_matlab(
desktop = desktop,
splash = splash,
display = display)
display = display,
wait = wait)
cmd = paste0(' "', "try, run('", fname, "'); ",
"catch err, disp(err.message); ",
"exit(1); end; exit(0);", '"')
Expand All @@ -124,7 +134,7 @@ run_matlab_script = function(
message("Command run is:")
message(cmd)
}
x <- system(cmd, ...)
x <- system(cmd, wait = wait, ...)
return(x)
}

Expand Down
5 changes: 4 additions & 1 deletion man/get_matlab.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion man/run_matlab_script.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1a130c3

Please sign in to comment.