home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21eb.zip / octave / SCRIPTS.ZIP / scripts / control / sysgroupn.m < prev    next >
Text File  |  1999-03-05  |  2KB  |  54 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 names = sysgroupn(names,kind)
  18. # names = sysgroupn(names)
  19. # locate and mark duplicate names
  20. # inputs:
  21. #   names: list of signal names
  22. #   kind: kind of signal name (used for diagnostic message purposes only)
  23. # outputs:
  24. #   returns names with unique suffixes added; diagnostic warning
  25. #      message is printed to inform the user of the new signal name
  26. #
  27. #  used internally in sysgroup
  28.  
  29.   # check for duplicate names
  30.   l = length(names);
  31.   ii = 1;
  32.   while(ii <= l-1)
  33.     st1 = nth(names,ii);
  34.     jj = ii+1;
  35.     while ( jj <= l)
  36.       st2 = nth(names,jj);
  37.       if(strcmp(st1,st2))
  38.         suffix = ["_",num2str(jj)];
  39.         warning("sysgroup: %s name(%d) = %s name(%d) = %s", ...
  40.       kind,ii,kind,jj,st1);
  41.         strval = sprintf("%s%s",st2,suffix);
  42.         names(jj) = strval;
  43.         warning("sysgroup:     changed %s name %d to %s",kind,jj,strval);
  44.         # restart the check (just to be sure there's no further duplications)
  45.         ii = 0; jj = l;
  46.       endif
  47.       jj = jj+1;
  48.     endwhile
  49.     ii = ii+1;
  50.   endwhile
  51. endfunction
  52.