Mercurial > hg > octave-nkf
view scripts/miscellaneous/open.m @ 19595:9e5b64b3c1fe
Fix up documentation for new disable_[range,diagonal_matrix,permutation_matrix] fcns.
* NEWS: Announce new functions disable_range, disable_diagonal_matrix,
disable_permutation_matrix.
* diagperm.txi: Add example showing space savings from using
disable_diagonal_matrix.
* ov.cc(Fdisable_range): Correct docstring which had cut-and-paste error
documenting disable_permutation_matrix instead. Add seealso links to
other disable_xxx functions.
* ov.cc(Fdisable_diagonal_matrix, Fdisable_permutation_matrix): Add seealso
links to other disable_xxx functions.
author | Rik <rik@octave.org> |
---|---|
date | Sat, 13 Dec 2014 18:41:03 -0800 |
parents | 030d56f67363 |
children | cbce5d1bcaf9 |
line wrap: on
line source
## Copyright (C) 2014 John W. Eaton ## ## This file is part of Octave. ## ## Octave is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## Octave is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- ## @deftypefn {Function File} {@var{output} =} open @var{file} ## @deftypefnx {Function File} {@var{output} =} open (@var{file}) ## Open the file @var{file} in Octave or in an external application ## based on the file type as determined by the file name extension. ## ## Recognized file types are ## ## @table @code ## @item .m ## Open file in the editor. ## @item .mat ## Load the file in the base workspace. ## @item .exe ## Execute the program (on Windows systems only). ## @end table ## ## Other file types are opened in the appropriate external application. ## @end deftypefn function output = open (file) if (nargin != 1) print_usage (); endif if (! ischar (file)) error ("expecting argument to be a file name"); endif [~, ~, ext] = fileparts (file); if (strcmpi (ext, ".m")) edit (file); elseif (strcmpi (ext, ".mat")) if (nargout > 0) output = load (file); else evalin ("base", sprintf ("load ('%s');", file)); endif elseif (any (strcmpi (ext, {".fig", ".mdl", ".slx", ".prj"}))) error ("opening file type '%s' is not supported", ext); elseif (strcmpi (ext, ".exe")) if (ispc ()) dos (file); else error ("executing .exe files is only supported on Windows systems"); endif else open_with_system_app (file); endif endfunction %% Test input validation %!error open %!error open (1) %!error output = open (1) function open_with_system_app (file) if (ispc ()) __w32_shell_execute__ (file); else ## FIXME: might not be xdg-open... system (sprintf ("xdg-open %s 2> /dev/null", file), false, "async"); endif endfunction