[Top][All Lists]

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

calling function with input arguments from commandline

From: John W. Eaton
Subject: calling function with input arguments from commandline
Date: Fri, 21 Oct 2005 08:57:55 -0400

On 21-Oct-2005, Martina Labahn wrote:

| I want to use the commandline to call the program octave + a
| function. The "octave -- funcall FUNCTION" option doesn't work
| because my function needs an input argument. The goal is to call
| this function from java. Therefore the restriction to a call from
| the commandline. The input argument is a file that should be loaded
| during the function.
| I would be happy if anyone could give me a hint how to solve this
| problem. Thanks

The current development version of Octave includes the following
options instead of --funcall:

  --eval CODE             Evaluate CODE.  Exit when done unless --persist.
  --persist               Go interactive after --eval or reading from FILE.

so you can write

  octave --eval "myfunction (arg1, arg2, ...)"

With older versions of Octave, you might be able to work around the
problem by writing

  myfunction (arg1, arg2, ...)

to a temporary file (say tmp-file), and then run

  octave tmp-file

to execute it.

If you make your function a script instead, then you can do as Bill
Denney suggested and get the arguments from the built-in variable
argv.  If you run

  octave script arg1 arg2 ...

then argv will be a cell array containing the character strings "arg1"
and "arg2".


Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:
How to fund new projects:
Subscription information:

reply via email to

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