help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Newbie question - how to return a value from Octave?


From: Richardson, Anthony
Subject: RE: Newbie question - how to return a value from Octave?
Date: Thu, 21 Jan 2010 10:36:30 -0600

ERRORLEVEL in Windows is equivalent to the exit status
variable in a UNIX shell.

Running  (from a Windows cmd prompt)

   octave    pi.m

Where pi.m contains

   pi
   exit(3)

will set ERRORLEVEL to 3 upon completion.

Tony Richardson


On Thursday, January 21, Carlo de Falco wrote:
> 
> 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.)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]