view m-toolbox/classes/@param/setDefaultIndex.m @ 3:960fe1aa1c10
database-connection-manager
Add LTPDADatabaseConnectionManager implementation. Java code
author
Daniele Nicolodi <nicolodi@science.unitn.it>
date
Mon, 05 Dec 2011 16:20:06 +0100 (2011-12-05)
parents
f0afece42f48
children
line source
+ − % SETDEFAULTINDEX Sets the index which points to the default value to the input.
+ − %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ − %
+ − % DESCRIPTION: SETDEFAULTINDEX Sets the index which points to the default
+ − % value to the input.
+ − %
+ − % CALL: obj = obj.setDefaultIndex(index);
+ − %
+ − % INPUTS: obj - A single param object
+ − % index - An index to the default option which should to be set.
+ − %
+ − % VERSION: $Id: setDefaultIndex.m,v 1.2 2011/02/22 15:51:44 hewitson Exp $
+ − %
+ − %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ −
+ − function p = setDefaultIndex(p, index)
+ −
+ − % Check input
+ − if numel(p) ~= 1
+ − error('### This method works only with one input parameter object.');
+ − end
+ − if ~isnumeric(index) && numel(index) ~= 1
+ − error('### This method works only with one input index.');
+ − end
+ −
+ − % Make a copy if the user doesn't use the modifier command
+ − p = copy(p, nargout);
+ −
+ − if isa(p.val, 'paramValue')
+ − if numel(p.val.options) >= index
+ − p.val.setValIndex(index);
+ − else
+ − error('### The number of param-options [%d] is for the new index [%d] not enough.', numel(p.val.options), index);
+ − end
+ − else
+ − warning('!!! This parameter [%s] has no options', p.key);
+ − end
+ −
+ − end
+ −