[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Multiple functions in a file
From: |
SZABO Sandor |
Subject: |
Re: Multiple functions in a file |
Date: |
Tue, 14 Nov 2000 17:36:13 +0100 |
Hello,
Etienne Grossmann wrote:
> Hello,
>
> From: Andy Adler <address@hidden>
>
> # Is it possible to put multiple function
> # definitions in a single *m file.
>
> In a script file (a file that does not start by a function
> definition), yes. For example :
>
> ======================================================================
> address@hidden: cat > foo.m
> 1;
What are these above? I obtained an error message:
error: invalid character `@' near line 1, column 9
parse error near line 1 of file /home/anal/sszabo/foo.m
>>> address@hidden: cat > foo.m
^
>
> function x=foo(y)
> x= 1+bar(y);
> endfunction
>
> function a=bar(b)
> a=b^2;
> endfunction
> address@hidden: fg
> octave (wd: ţ)
>
And what are the above two lines?
>
> octave:16> which foo
> which: `foo' is the script file
> /home/etienne/prog/octave/mylib/foo.m
> octave:17> foo
> warning: function `foo' defined within script file
> `/home/etienne/prog/octave/mylib/foo.m'
> octave:18> which foo
> foo is a user-defined function
> octave:19> foo (3)
> ans = 10
> ======
foo works well. What about bar?
> ================================================================
>
> Note that I first had to call 'foo' as a script so that the
> functions get declared.
>
> To avoid the warning, you could name the script 'foo_decl_script' or
> someting alike.
>
> # But I'd really like to be able to do this,
> # as I don't want people to bar to be accessible directly.
>
> I think 'bar' will always be visible.
>
> Hth,
>
> Etienne
>
> -------------------------------------------------------------
> 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
-------------------------------------------------------------