Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

inputParser help

26 views
Skip to first unread message

venkat

unread,
Nov 11, 2009, 7:29:32 AM11/11/09
to
I have a class as:
classdef classA
properties
string
enable
fontsize
end
methods
function obj = classA(varargin)
p=inputParser;

p.addParamValue('string', 'New String', @ischar);
p.addParamValue('enable', true, @islogical);
p.addParamValue('fontsize', 10, @isnumeric);

p.parse(varargin{:});

obj.string = p.Results.string;
obj.enable = p.Results.enable;
obj.fontsize = p.Results.fontsize;

end
end
end

This works: obj1 = classA('string', 'hai')
but I wiould like to also use: obj2 = classA('str', 'hai') or obj3 =
classA('stri', 'hai')
i.e using short form of parser parameters I want to run my class.
Using 'str' or 'stri' or 'strin' etc must work as similar to using
'string' in the arguments. Can any one suggest me on this??
(like uicontrol('str', 'hello', 'pos', [10 10 50 20]))

Message has been deleted

venkat

unread,
Nov 11, 2009, 9:01:36 AM11/11/09
to
something like we can use
uicontrol('string', 'hello', 'position', [10 10 50 20], 'units',
'pixels')
or
uicontrol('str', 'hello', 'pos', [10 10 50 20], 'uni', 'pixels')
so in the similar way I want to have the parsing in the above class

thanks in advance!!


0 new messages