[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Newbie question - how to return a value from Octave?
From: |
Carlo de Falco |
Subject: |
Re: Newbie question - how to return a value from Octave? |
Date: |
Thu, 21 Jan 2010 17:26:23 +0100 |
On 21 Jan 2010, at 16:26, David Aldrich wrote:
Hi
I am new to Octave. I want to use Octave in an automated build
system to run regression tests. Each regression test will be
executed by a Matlab function that will return an integer indicating
the test result. I need to be able to invoke that function by
running Octave, and for Octave to return the function result.
For example, I want to be able to run something like:
C:\> Octave pi
and for the Windows environment variable %ERRORLEVEL% to be set to 3
(an alternative solution in Linux would be acceptable).
Is this possible and what is the exact command line syntax please?
Best regards
David
I know nothing about windows, but on any Unix system you can do
something like
guglielmo.local $ export ERRORLEVEL=`octave -q --eval
"fprintf('%1.1g',pi)"`
guglielmo.local $ printenv ERRORLEVEL
3
guglielmo.local $ export ERRORLEVEL=`octave -q --eval
"fprintf('%g',pi)"`
guglielmo.local $ printenv ERRORLEVEL
3.14159
the exact syntax will of course depend on the shell, the above is for
bash.
On the other hand, depending on your application, launching one
instance of Octave
any time you need to change the value of an environment variable might
not be the best
option in terms of efficiency, and you might be rather interested in
some sort of interprocess
communication mechanism (e.g. pipes, sockets, etc.)
HTH,
c.