home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21eb.zip / octave / SCRIPTS.ZIP / scripts / control / sysdefioname.m < prev    next >
Text File  |  1999-03-05  |  2KB  |  50 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 ioname = sysdefioname(n,str,m)
  18. # function ioname = sysdefioname(n,str[,m])
  19. # return list of default input or output names given n, str, m
  20. # n is the final value, str is the string prefix, and m is start value
  21. # ex: ioname = sysdefioname(5,"u",3)
  22. #
  23. # returns:     ioname =
  24. #               (
  25. #                 [1] = u_3
  26. #                 [2] = u_4
  27. #                 [3] = u_5
  28. #               )
  29. # used internally, minimal argument checking
  30.  
  31.   if (nargin < 2 | nargin > 3)
  32.     usage("ioname = sysdefioname(n,str[,m])");
  33.   endif
  34.  
  35.   if (nargin == 2)           m = min(1,n);            endif
  36.  
  37.   ioname = list();
  38.   jj = 1;
  39.   if(n > 0 & m > 0 & m <= n)
  40.     for ii = m:n
  41.       ioname(ii+1-m) = sprintf("%s_%d",str,ii);
  42.     endfor
  43.   elseif(m > n)
  44.     error("str=%s; start value m=%d > final value n=%d",str,m,n);
  45.   endif
  46.  
  47. endfunction
  48.