Skip to content

Commit 5fd337c

Browse files
authored
Add flag options to MSession (#138)
1 parent 4360596 commit 5fd337c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/engine.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
#
77
###########################################################
88
const default_matlabcmd = matlabcmd * " -nosplash"
9+
const default_startflag = "-nosplash"
10+
# pass matlab flags directly or as a Vector of flags, i.e. "-a" or ["-a", "-b", "-c"]
11+
startcmd(flag::AbstractString = default_startflag) = default_matlabcmd * " " * flag
12+
startcmd(flags::AbstractVector{T}) where {T<:AbstractString} = default_matlabcmd * " " * join(flags, " ")
913

1014
# 64 K buffer should be sufficient to store the output text in most cases
1115
const default_output_buffer_size = 64 * 1024
@@ -15,12 +19,11 @@ mutable struct MSession
1519
buffer::Vector{UInt8}
1620
bufptr::Ptr{UInt8}
1721

18-
function MSession(bufsize::Integer = default_output_buffer_size)
22+
function MSession(bufsize::Integer = default_output_buffer_size; flags=default_startflag)
1923
if iswindows()
2024
assign_persistent_msession()
2125
end
22-
23-
ep = ccall(eng_open[], Ptr{Cvoid}, (Ptr{UInt8},), default_matlabcmd)
26+
ep = ccall(eng_open[], Ptr{Cvoid}, (Ptr{UInt8},), startcmd(flags))
2427
if ep == C_NULL
2528
@warn("Confirm MATLAB is installed and discoverable.", maxlog=1)
2629
if iswindows()

0 commit comments

Comments
 (0)