3437
|
1 ## Copyright (C) 1996 Auburn University. All rights reserved. |
|
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 ## |
|
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 |
|
12 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 ## for more details. |
|
14 ## |
|
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 |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301 USA. |
3437
|
19 |
6945
|
20 ## Undocumented internal function. |
|
21 |
3437
|
22 ## -*- texinfo -*- |
3500
|
23 ## @deftypefn {Function File} {} __syschnamesl__ (@var{olist}, @var{old_names}, @var{inames}, @var{listname}) |
3437
|
24 ## used internally in syschnames |
|
25 ## item olist: index list |
|
26 ## old_names: original list names |
|
27 ## inames: new names |
|
28 ## listname: name of index list |
|
29 ## |
|
30 ## combines the two string lists old_names and inames |
|
31 ## @end deftypefn |
|
32 |
3438
|
33 function old_names = __syschnamesl__ (olist, old_names, inames, listname) |
3437
|
34 |
|
35 probstr = []; |
|
36 if( max(olist) > rows(old_names) ) |
|
37 probstr = ["index list value(s) exceed(s) number of signals (", ... |
|
38 num2str(rows(old_names)),")"]; |
|
39 |
|
40 elseif( length(olist) > rows(inames) ) |
|
41 probstr = ["index list dimension exceeds number of replacement names (", ... |
|
42 num2str(rows(inames)),")"]; |
|
43 |
|
44 elseif(isempty(olist)) |
|
45 probstr = []; # do nothing, no changes |
|
46 |
|
47 elseif(min(size(olist)) != 1 ) |
|
48 probstr = "index list must be either a vector or an empty matrix"; |
|
49 |
|
50 elseif(max(olist) > rows(old_names)) |
|
51 probstr = ["max(",listname,")=",num2str(max(olist))," > ", ... |
|
52 num2str(rows(old_names)),", too big"]; |
|
53 |
|
54 elseif(min(olist) < 1) |
|
55 probstr = ["min(",listname,")=",num2str(min(olist))," < 1, too small"]; |
|
56 |
|
57 else |
|
58 if( length(olist) == 1) |
|
59 len_in = columns(inames); |
|
60 len_out = columns(old_names); |
|
61 |
|
62 if (len_in < len_out) |
|
63 inames(1,(len_in+1):(len_out)) = zeros(1,(len_out - len_in)); |
|
64 endif |
|
65 |
|
66 old_names(olist,1:length(inames)) = inames; |
|
67 elseif(length(olist) > 1) |
|
68 for ii=1:length(olist) |
|
69 mystr = inames(ii,:); |
|
70 len_my = columns(mystr); |
|
71 len_out = columns(old_names); |
|
72 |
|
73 if (len_my < len_out) |
|
74 mystr(1,(len_my+1):(len_out)) = " "*ones(1,(len_out - len_my)); |
|
75 len_my = len_out; |
|
76 endif |
|
77 |
|
78 old_names(olist(ii),1:len_my) = mystr; |
|
79 endfor |
|
80 endif |
|
81 endif |
|
82 if(!isempty(probstr)) |
|
83 ## the following lines are NOT debugging code! |
|
84 disp("Problem in syschnames: old names are") |
3438
|
85 __outlist__(old_names," ") |
3437
|
86 disp("new names are") |
3438
|
87 __outlist__(inames," ") |
3437
|
88 disp("list indices are") |
|
89 disp(olist) |
|
90 error(sprintf("syschnames: \"%s\" dim=(%d x %d)--\n\t%s\n", ... |
|
91 listname, rows(olist), columns(olist),probstr)); |
|
92 endif |
|
93 |
|
94 ## change zeros to blanks |
|
95 if( find(old_names == 0) ) |
3438
|
96 ## disp("__syschnamesl__: old_names contains zeros ") |
3437
|
97 ## old_names |
3438
|
98 ## disp("/__syschnamesl__"); |
3437
|
99 |
|
100 [ii,jj] = find(old_names == 0); |
|
101 for idx=1:length(ii) |
|
102 old_names(ii(idx),jj(idx)) = " "; |
|
103 endfor |
|
104 |
3438
|
105 ## disp("__syschnamesl__: old_names fixed zeros ") |
3437
|
106 ## old_names |
3438
|
107 ## disp("/__syschnamesl__"); |
3437
|
108 endif |
|
109 |
|
110 ## just in case it's not a string anymore |
5443
|
111 if( !ischar(old_names) ) |
|
112 old_names = char(old_names); |
3437
|
113 endif |
|
114 |
3438
|
115 ## disp("__syschnamesl__: exit, old_names=") |
3437
|
116 ## old_names |
3438
|
117 ## disp("/__syschnamesl__: exiting") |
3437
|
118 |
|
119 endfunction |