Mercurial > hg > octave-nkf
annotate scripts/miscellaneous/recycle.m @ 17804:f3e25230b1f3
use QCoreApplication if starting with --no-gui
* octave-gui.cc (octave_start_gui): Use QApplication when starting
the GUI and QCoreApplication if not.
(octave_cli_thread::run): Call QCoreApplication::exit instead of
QApplication::exit.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 30 Oct 2013 02:08:41 -0400 |
parents | d63878346099 |
children | 6cf253a39fde |
rev | line source |
---|---|
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
15776
diff
changeset
|
1 ## Copyright (C) 2012-2013 John W. Eaton |
13840
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 -*- |
15776 | 20 ## @deftypefn {Function File} {@var{current_state} =} recycle () |
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 ## |
15776 | 24 ## Recycling files, instead of permanently deleting them, is not currently |
25 ## implemented in Octave. To help avoid accidental data loss an error | |
26 ## will be raised if an attempt is made to enable file recycling. | |
13840
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 |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
51 error ("recycle: invalid value of STATE = '%s'", state); |
13840
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 |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
54 error ("recycle: STATE must 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 |
69afe121f07e
provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
61 %!test |
69afe121f07e
provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
62 %! recycle ("off"); |
69afe121f07e
provide parial implementation of the recycle function
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
63 %! assert (recycle ("off"), "off"); |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
64 |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
65 %!error <recycling files is not implemented> recycle ("on") |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
66 %!error recycle ("on", "and I mean it") |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
67 %!error <STATE must be a character string> recycle (1) |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
68 |