This function sources an Octave file within the current
Octave session. The loaded functions are accessible by
subsequent calls of .CallOctave
.
o_source(file = "", text = NULL, sep = ";\n")
o_eval
.text
. The concatenation of all
suffixed element should form a valid Octave
block.None
-- Built-in Function: source (FILE) Parse and execute the contents of FILE. This is equivalent to executing commands from a script file, but without requiring the file to be named 'FILE.m'.
[Generated from Octave-3.6.4 on 2014-05-21 11:08:21 ]
## Don't show:
# roxygen generated flag
options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
## End Don't show
## Don't show:
o_clear()
## End Don't show
# source file
mfile <- system.file("scripts/ex_source.m", package='RcppOctave')
o_source(mfile)
# pass multiple statements
o_source(text="a=1;b=3;c=randn(1,5);")
o_get('a','b','c')
## $a
## [1] 1
##
## $b
## [1] 3
##
## $c
## [1] -1.2651 -0.6869 -0.4457 1.2241 0.3598
# also works with a character vector of statements
o_source(text=c("a=10;b=30;", "c=randn(1,5)", "d=4"))
o_get('a','b','c', 'd')
## $a
## [1] 10
##
## $b
## [1] 30
##
## $c
## [1] 0.4008 0.1107 -0.5558 1.7869 0.4979
##
## $d
## [1] 4