annotate scripts/miscellaneous/recycle.m @ 13918:043aead8ed89

Remove recycle from list of unimplemented functions * unimplemented.m: Remove recycle from list. * recycle.m: Correct typo in code. Use standard phrasing in docstring.
author Rik <octave@nomad.inbox5.com>
date Tue, 22 Nov 2011 19:50:06 -0800
parents 69afe121f07e
children 9cae456085c2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13840
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 ## Copyright (C) 2011 John W. Eaton
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2 ##
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3 ## This file is part of Octave.
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4 ##
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8 ## your option) any later version.
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9 ##
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13 ## General Public License for more details.
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 ##
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 ## -*- texinfo -*-
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20 ## @deftypefn {Function File} {@var{current_state}} recycle ()
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 ## @deftypefnx {Function File} {@var{old_state}} recycle (@var{new_state})
13918
043aead8ed89 Remove recycle from list of unimplemented functions
Rik <octave@nomad.inbox5.com>
parents: 13840
diff changeset
22 ## Query or set the preference for recycling deleted files.
13840
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23 ##
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24 ## Recycling files instead of permanently deleting them is currently not
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25 ## implemented in Octave. To help avoid accidental data loss it
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 ## is an error to attempt enable file recycling.
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 ## @seealso{delete}
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 ## @end deftypefn
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 ## Author: jwe
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 function retval = recycle (state)
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 persistent current_state = "off";
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 if (nargin > 1)
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 print_usage ();
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 endif
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 if (nargin == 0 || nargout > 0)
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 retval = current_state;
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 endif
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44 if (nargin == 1)
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45 if (ischar (state))
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46 if (strcmpi (state, "on"))
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47 error ("recycle: recycling files is not implemented");
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48 elseif (strcmpi (state, "off"))
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49 current_state = "off";
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 else
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51 error ("recycle: invalid value of STATE = `%s'", state);
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 endif
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53 else
13918
043aead8ed89 Remove recycle from list of unimplemented functions
Rik <octave@nomad.inbox5.com>
parents: 13840
diff changeset
54 error ("recycle: expecting STATE to be a character string");
13840
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55 endif
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56 endif
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58 endfunction
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60 %!error recycle ("on");
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61 %!error recycle ("on", "and I mean it");
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62 %!error recycle (1);
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64 %!test
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65 %! recycle ("off");
69afe121f07e provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66 %! assert (recycle ("off"), "off");