1 function [x, over] = df_strset(x, over, S, RHS, pad = ' ')
2 %# x = df_strset(x, over, S, RHS, pad = " ")
3 %# replaces the strings in cellstr x at indr by strings at y. Adapt
4 %# the width of x if required. Use x 'over' attribute to display a
5 %# message in case strings are overwritten.
7 %% Copyright (C) 2009-2012 Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
9 %% This file is part of Octave.
11 %% Octave is free software; you can redistribute it and/or
12 %% modify it under the terms of the GNU General Public
13 %% License as published by the Free Software Foundation;
14 %% either version 2, or (at your option) any later version.
16 %% Octave is distributed in the hope that it will be useful,
17 %% but WITHOUT ANY WARRANTY; without even the implied
18 %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
19 %% PURPOSE. See the GNU General Public License for more
22 %% You should have received a copy of the GNU General Public
23 %% License along with Octave; see the file COPYING. If not,
24 %% write to the Free Software Foundation, 51 Franklin Street -
25 %% Fifth Floor, Boston, MA 02110-1301, USA.
28 %# $Id: df_strset.m 9585 2012-02-05 15:32:46Z cdemills $
31 %# adjust x size, if required
35 x = cell(0, 1); over = zeros(1, 0);
38 dummy = S; dummy(1).subs(2:end) = [];
39 over = builtin('subsasgn', over, dummy, true);
41 if isempty(S), %# complete overwrite
42 if ischar(RHS), RHS = cellstr(RHS); endif
45 warning('going to overwrite names');
50 x(nrow+1:end) = {pad};
54 dummy = S(1); dummy.subs(2:end) = []; % keep first dim only
55 if any(~(builtin('subsref', over, dummy)));
56 warning('going to overwrite names');
58 over = builtin('subsasgn', over, dummy, false);
63 if ischar(RHS) && length(S(1).subs) > 1,
64 %# partial accesses to a char array
66 dummy = builtin('subsasgn', dummy, S, RHS);
68 x = cell(0, 1); over = zeros(1, 0);
71 if size(dummy, 1) == length(x),
75 %# partial clearing gone wrong ? retry
78 x = builtin('subsasgn', x, S, RHS);