Mercurial > hg > octave-nkf
comparison scripts/control/outlist.m @ 3381:69b167451491
[project @ 1999-12-15 20:48:10 by jwe]
author | jwe |
---|---|
date | Wed, 15 Dec 1999 20:48:45 +0000 |
parents | 8dd4718801fd |
children | 10f21f7ccc7f |
comparison
equal
deleted
inserted
replaced
3380:f5edd74bdc6c | 3381:69b167451491 |
---|---|
1 # Copyright (C) 1996, 1998 Auburn University. All Rights Reserved. | 1 ## Copyright (C) 1996, 1998 Auburn University. All Rights Reserved. |
2 # | 2 ## |
3 # This file is part of Octave. | 3 ## This file is part of Octave. |
4 # | 4 ## |
5 # Octave is free software; you can redistribute it and/or modify it | 5 ## Octave is free software; you can redistribute it and/or modify it |
6 # under the terms of the GNU General Public License as published by the | 6 ## under the terms of the GNU General Public License as published by the |
7 # Free Software Foundation; either version 2, or (at your option) any | 7 ## Free Software Foundation; either version 2, or (at your option) any |
8 # later version. | 8 ## later version. |
9 # | 9 ## |
10 # Octave is distributed in the hope that it will be useful, but WITHOUT | 10 ## Octave is distributed in the hope that it will be useful, but WITHOUT |
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | 11 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | 12 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
13 # for more details. | 13 ## for more details. |
14 # | 14 ## |
15 # You should have received a copy of the GNU General Public License | 15 ## You should have received a copy of the GNU General Public License |
16 # along with Octave; see the file COPYING. If not, write to the Free | 16 ## along with Octave; see the file COPYING. If not, write to the Free |
17 # Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. | 17 ## Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. |
18 | 18 |
19 ## -*- texinfo -*- | 19 ## -*- texinfo -*- |
20 ## @deftypefn {Function File } { } outlist (@var{lmat}@{, @var{tabchar}, @var{yd}, @var{ilist} @}) | 20 ## @deftypefn {Function File } { } outlist (@var{lmat}@{, @var{tabchar}, @var{yd}, @var{ilist} @}) |
21 ## Prints an enumerated list of strings. | 21 ## Prints an enumerated list of strings. |
22 ## internal use only; minimal argument checking performed | 22 ## internal use only; minimal argument checking performed |
41 ## prints the list to the screen, numbering each string in order. | 41 ## prints the list to the screen, numbering each string in order. |
42 ## | 42 ## |
43 ## @end deftypefn | 43 ## @end deftypefn |
44 | 44 |
45 function str_val = outlist(name_list,tabchar,yd,ilist) | 45 function str_val = outlist(name_list,tabchar,yd,ilist) |
46 # A. S. Hodel Dec. 1995, 1998 | |
47 | 46 |
48 #save for restore later | 47 ## A. S. Hodel Dec. 1995, 1998 |
49 save_empty = empty_list_elements_ok; | |
50 empty_list_elements_ok = 1; | |
51 | 48 |
52 if( nargin < 1 | nargin > 4 ) | 49 ## save for restore later |
53 usage("str_val = outlist(x[,tabchar,yd,ilist])"); | 50 save_empty = empty_list_elements_ok; |
54 endif | 51 empty_list_elements_ok = 1; |
55 | 52 |
56 m = length(name_list); | 53 if( nargin < 1 | nargin > 4 ) |
57 if(nargin < 4) ilist = 1:m; endif | 54 usage("str_val = outlist(x[,tabchar,yd,ilist])"); |
58 if(nargin ==1) | 55 endif |
59 empty_list_elements_ok = 1; | |
60 tabchar = ""; | |
61 endif | |
62 | 56 |
63 if(nargin < 3) yd = zeros(1,m); | 57 m = length(name_list); |
64 elseif(isempty(yd)) yd = zeros(1,m); endif | 58 if(nargin < 4) ilist = 1:m; endif |
59 if(nargin ==1) | |
60 empty_list_elements_ok = 1; | |
61 tabchar = ""; | |
62 endif | |
65 | 63 |
66 str_val = ""; | 64 if(nargin < 3) yd = zeros(1,m); |
67 dstr = list(""," (discrete)"); | 65 elseif(isempty(yd)) yd = zeros(1,m); endif |
68 if((m >= 1) && (is_list(name_list))) | |
69 for ii=1:m | |
70 str_val = sprintf("%s%s%d: %s%s\n",str_val,tabchar, ilist(ii), ... | |
71 nth(name_list,ii),nth(dstr,yd(ii)+1)); | |
72 endfor | |
73 else | |
74 str_val = sprintf("%sNone",tabchar); | |
75 endif | |
76 | 66 |
77 empty_list_elements_ok = save_empty; | 67 str_val = ""; |
68 dstr = list(""," (discrete)"); | |
69 if((m >= 1) && (is_list(name_list))) | |
70 for ii=1:m | |
71 str_val = sprintf("%s%s%d: %s%s\n",str_val,tabchar, ilist(ii), ... | |
72 nth(name_list,ii),nth(dstr,yd(ii)+1)); | |
73 endfor | |
74 else | |
75 str_val = sprintf("%sNone",tabchar); | |
76 endif | |
77 | |
78 empty_list_elements_ok = save_empty; | |
79 | |
78 endfunction | 80 endfunction |