| I have a "feature" request.
| Everyone here starts all there programs with:
| clear all
| close all
| While the first line works fine. The second generates an error. It's a
| bad first experience. It should close all the plot windows. I guess
| "close" has to be made a octave keyword? You said something a long time
| ago about allowing "close all" to be equivalent of "close(all)". If
| that was the case it could be implemented as a m-file either way.
| Getting octave to somehow accept "close" and "set" command would be a
| nice step forward for compatibility.
I've just added a close function to CVS Octave, implemented as an
M-file. It can really only handle "close all" or "close" (but even
then, it closes all the windows, because there seems to be no way to
tell gnuplot to close only one). It can't close figures by name or
handle because we don't have figure handles or named figures.
It has only recently become possible to define command-style functions
in M-files. Unlike Matlab, Octave does not do any special tricks to
decide whether it is parsing a command. The reason I don't want to
make Octave behave exactly like Matlab in this case is that I want to
avoid ambiguities like
is this an expression (subtract one the result of some_function) or a
command with the string argument "-1"? Matlab parses it as a command
with a string argument. But if you write
some_function - 1
Matlab will parse it as a binary expression. Another bad case of
whitespace being special. We've gone over this on the list before, so
I won't rehash all of that.
Instead of the kind of kluge that Matlab uses, Octave has another:
you have to tell Octave that a given function name can be a command
using the new command "mark_as_command".
There is also some new code for declaring commands at startup time.
Now when a directory is added to the LOAADPATH, Octave looks for a
file called PKG_ADD in the directory, and if it is present, reads and
executes commands from it.
When Octave is installed, it builds the PKG_ADD files for the M-file
directories that it installs. Currently, the script that builds the
PKG_ADD files looks for comments that start with "## PKG_ADD: "
in M-files that are installed and converts them to commands. For
## PKG_ADD: mark_as_command name
is converted to
in the corresponding PKG_ADD file. So, the close.m file looks like
## copyright info ...
## PKG_ADD: mark_as_command close
function retval = close (arg1, arg2)
... rest of function ...
We may eventually add other functionality to the PKG_ADD scripts.
Octave also looks for a PKG_DEL script when a directory is removed
from the LOADPATH, but so far there are no PKG_DEL scripts (I'm not
sure that it is necessary to unmark commands, but if people think that
makes sense, it would be easy to add).