source: MML/trunk/machine/SOLEIL/common/toolbox/GUILayout/+uiextras/findArg.m @ 4

Last change on this file since 4 was 4, checked in by zhangj, 10 years ago

Initial import--MML version from SOLEIL@2013

File size: 970 bytes
Line 
1function value = findArg( argname, varargin )
2%findArg  Find a specific property value from a property-value pairs list
3%
4%   value = findParentArg(propname,varargin) parses the inputs as property-value
5%   pairs looking for the named property. If found, the corresponding
6%   value is returned. If not found an empty array is returned.
7%
8%   Examples:
9%   >> uiextras.findArg('Parent','Padding',5,'Parent',1,'Visible','on')
10%   ans =
11%     1
12
13%   Copyright 2009-2010 The MathWorks, Inc.
14%   1.1
15%   2012/05/08 08:02:58
16
17error( nargchk( 1, inf, nargin, 'struct' ) );
18
19value = [];
20if nargin>1
21    props = varargin(1:2:end);
22    values = varargin(2:2:end);
23    if ( numel( props ) ~= numel( values ) ) || any( ~cellfun( @ischar, props ) )
24        error( 'GUILayout:InvalidSyntax', 'Arguments must be supplied as property-value pairs.' );
25    end
26    myArg = find( strcmpi( props, argname ), 1, 'last' );
27    if ~isempty( myArg )
28        value = values{myArg};
29    end
30end
Note: See TracBrowser for help on using the repository browser.