[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: liboctave and scripts
From: |
Paul Kienzle |
Subject: |
Re: liboctave and scripts |
Date: |
Tue, 2 Apr 2002 14:42:14 -0500 |
As Doug Eck discovered earlier, you need to do necessary initializations
if you want to call octave functions. In his case, he just needed the
symbol table defined to use the load/save functions.
In your case you will be interpreting arbitrary code so you will need to
initialize everything. I don't know what "everything" is. You could scan
through toplev.c to find it, but that would be silly when you can just
replace your main() with DEFUN_DLD(main,args,,"") and define an executable
script myprog:
#!/usr/bin/octave -q
main(argv)
Here is an example of how to call an interpreter function from C++:
void dotest() {
octave_value_list args;
args(0)="tst.mat";
args(1)="a";
cout << "Loading file " << args(0).string_value() << " ... ";
feval("load", args, 0); // no arguments returned from load
cout << "success" << endl;
cout << "Fetching variable (" << args(1).string_value() << ") from symbol
table... ";
octave_value a = get_value("a");
if (!error_state) {
cout << "success" << endl;
cout << "Displaying value "<< endl;
a.print(cout);
}
}
Paul Kienzle
address@hidden
On Tue, Apr 02, 2002 at 08:42:29PM +0200, Pablo Barrera González wrote:
> Hello
>
> I'm using liboctave in a C program. I also have some octave script
> function (not a built-in function) that I would like to use in that
> program. How could I call a interpreter from my program without running
> the octave program (i.e. system("octave"))? I also want that the script
> could change without rebuilding the C program.
>
> Thank you.
>
>
> --
> ---------------------------------------------------------------
> Pablo Barrera Gonzalez
> Ingenieria en Telecomunicaciones
> Universidad Carlos III de Madrid
> ---------------------------------------------------------------
>
>
>
>
> -------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
>
> Octave's home on the web: http://www.octave.org
> How to fund new projects: http://www.octave.org/funding.html
> Subscription information: http://www.octave.org/archive.html
> -------------------------------------------------------------
>
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------