[changeset] property value not paired with name in __add_datasource__.m
Ben Abbott
bpabbott at mac.com
Mon Sep 1 08:55:30 CDT 2008
On Sep 1, 2008, at 9:35 AM, David Bateman wrote:
> Ben Abbott wrote:
>>
>> On Sep 1, 2008, at 9:06 AM, Ben Abbott wrote:
>>
>>> The script __add_datasource__ does not preserve the property values.
>>>
>>> I'm confused as to how __add_datasource__ is intended to work. Is
>>> this behavior correct?
>>>
>>> If yours works properly (different, I assume), perhaps our
>>> sources are out of sync?
>>>
>>> Ben
>>
>> I'm presently unable to pull from jwe's archive :-(
>>
>> To apply David's patch I edited the sources myself. My archive is
>> now a bit of a mess :-(
>>
>> In any event, I have a solution (I think). The functioning code for
>> *my* __add_datasource__.m is below. I've modified line 37. It was
>> "while (i < numel (varargin))".
>>
>> David, the test plot you suggested works now. Is my inferred
>> solution proper?
>>
>> 21 function newargs = __add_datasource__ (fcn, h, data, varargin)
>> 22
>> 23 if (nargin < 3)
>> 24 error ("internal error");
>> 25 endif
>> 26
>> 27 if (ischar (data))
>> 28 data = {data};
>> 29 endif
>> 30
>> 31 for i = 1 : numel (data)
>> 32 addproperty (strcat (data{i}, "datasource"), h, "string", "");
>> 33 endfor
>> 34
>> 35 i = 1;
>> 36 newargs = {};
>> 37 while (i <= numel (varargin))
>> 38 arg = varargin{i++};
>> 39 if (ischar (arg) && length (arg > 1) && strcmpi (arg(2:end),
>> "datasource"))
>> 40 arg = tolower (arg);
>> 41 val = varargin{i++};
>> 42 if (ischar (val))
>> 43 set (h, arg, val);
>> 44 else
>> 45 error ("%s: expecting data source to be a string", fcn);
>> 46 endif
>> 47 else
>> 48 newargs{end + 1} = arg;
>> 49 endif
>> 50 endwhile
>> 51 endfunction
>>
>> Ben
>>
>>
>
> Ok, we are out of sync.. My __add_datasource__ reads..
>
> function newargs = __add_datasource__ (fcn, h, data, varargin)
>
> if (nargin < 3)
> error ("internal error");
> endif
>
> if (ischar (data))
> data = {data};
> endif
>
> for i = 1 : numel (data)
> addproperty (strcat (data{i}, "datasource"), h, "string", "");
> endfor
>
> i = 0;
> newargs = {};
> while (i < numel (varargin))
> arg = varargin{++i};
> if (i != numel(varargin) && ischar (arg) &&
> length (arg > 1) && strcmpi (arg(2:end), "datasource"))
> arg = tolower (arg);
> val = varargin{++i};
> if (ischar (val))
> set (h, arg, val);
> else
> error ("%s: expecting data source to be a string", fcn);
> endif
> else
> newargs{end + 1} = arg;
> endif
> endwhile
> endfunction
>
> As you say I can't check what John actually has in his repository as
> I can't get to it at the moment.
>
> D.
I manually replaced my __add_datasource__ with yours. All works now!
Ben
More information about the Octave-maintainers
mailing list