home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21eb.zip / octave / SCRIPTS.ZIP / scripts / control / outlist.m < prev    next >
Text File  |  1999-03-05  |  2KB  |  69 lines

  1. # Copyright (C) 1996, 1998 A. Scottedward Hodel 
  2. #
  3. # This file is part of Octave. 
  4. #
  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 
  7. # Free Software Foundation; either version 2, or (at your option) any 
  8. # later version. 
  9. # Octave is distributed in the hope that it will be useful, but WITHOUT 
  10. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
  11. # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
  12. # for more details.
  13. # You should have received a copy of the GNU General Public License 
  14. # along with Octave; see the file COPYING.  If not, write to the Free 
  15. # Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
  16.  
  17. function str_val = outlist(name_list,tabchar,yd,ilist)
  18. # function str_val = outlist(name_list[,tabchar,yd,ilist])
  19. #
  20. # internal use only; minimal argument checking performed
  21. #
  22. # print an enumerated list of strings
  23. # inputs:
  24. #    name_list: list of strings (one per entry)
  25. #    tabchar: tab character (default: none)
  26. #       yd: indices of entries to append with the string "(discrete)"
  27. #           (used by sysout; minimal checking of this argument)
  28. #       yd = [] => all continuous
  29. #       ilist: index numbers to print with names
  30. #      default: 1:length(name_list)
  31. # outputs:
  32. #   prints the list to the screen, numbering each string in order.
  33.  
  34. # A. S. Hodel Dec. 1995, 1998
  35.  
  36. #save for restore later
  37. save_empty = empty_list_elements_ok;
  38. empty_list_elements_ok = 1;
  39.  
  40. if( nargin < 1 | nargin > 4 )
  41.   usage("str_val = outlist(x[,tabchar,yd,ilist])");
  42. endif
  43.  
  44. m = length(name_list);
  45. if(nargin < 4)           ilist = 1:m;          endif
  46. if(nargin ==1)
  47.   empty_list_elements_ok = 1;
  48.   tabchar = "";
  49. endif
  50.  
  51. if(nargin < 3)             yd = zeros(1,m);
  52. elseif(isempty(yd))        yd = zeros(1,m);          endif
  53.  
  54. str_val = "";
  55. dstr = list(""," (discrete)");
  56. if((m >= 1) && (is_list(name_list)))
  57.   for ii=1:m
  58.     str_val = sprintf("%s%s%d: %s%s\n",str_val,tabchar, ii, ...
  59.     nth(name_list,ii),nth(dstr,yd(ii)+1));
  60.   endfor
  61. else
  62.   str_val = sprintf("%sNone",tabchar);
  63. endif
  64.  
  65. empty_list_elements_ok = save_empty;
  66. endfunction
  67.