help-octave
[Top][All Lists]
Advanced

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

arguments to scripts...


From: John W. Eaton
Subject: arguments to scripts...
Date: Fri, 27 Mar 1998 11:39:50 -0600

On 27-Mar-1998, Stefano Ghirlanda <address@hidden> wrote:

| pardon me for the possibly trivial question:
| how do you pass arguments to a script file?
| Is there something like the $1, $2 etc. shell parameters?

You don't say which version of Octave you are using, or exactly how
you want to call your script.

With the current release, if you make an executable program out of
your script using the `#! /path/to/octave' hack available on most Unix
systems, you can do something like this

  #! /path/to/octave -qf
  printf ("%s", program_name);
  for i = 1:nargin
    printf (" %s", argv(i,:));
  endfor
  printf ("\n");

and

  ./program-name foo bar etc

will reproduce the command line on the standard output.

If you want to call your script from the Octave command line, you can
either use variables in the workspace (variables in script files are
share the same scope with the calling procedure) or you can convert
your script to a function and pass arguments to it in the normal way
for calling functions.

jwe



reply via email to

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