[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
embedding function
From: |
John W. Eaton |
Subject: |
embedding function |
Date: |
Fri, 14 Sep 2001 10:13:56 -0500 |
On 14-Sep-2001, Q. Peter He <address@hidden> wrote:
| Hi all,
|
| I'm trying to write a code which deals with embedding functions:
|
| Here is my code test.m
|
| #!/usr/bin/octave -qH
|
| type=str2num(nth(argv,1));
|
| if type == 1
| test1(argv);
| else
| test2(argv);
| endif
|
| function test1(...)
| argv
| endfunction
|
| function test2(...)
| argv
| endfunction
|
| When I tried to run this code, I got the following message:
|
| error: 'test1' undefined near line 4 column 3
| error: evaluating index expression near line 4, column 3
| error: evaluating if command near line 3, column 1
|
| I heard that Octave actually support such type of embedding functions.
| Should I define a main function some where?
Define before invoking and make sure the first non-comment token in
the file is not the keyword "function". The following should work.
#!/usr/bin/octave -qH
1; # not a function file.
function test1(...)
argv
endfunction
function test2(...)
argv
endfunction
type=str2num(nth(argv,1));
if type == 1
test1(argv);
else
test2(argv);
endif
jwe
-------------------------------------------------------------
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
-------------------------------------------------------------