Mercurial > hg > ltpda
view m-toolbox/classes/@LTPDAworkbench/executeConstants.m @ 50:7d2e2e065cf1 database-connection-manager
Update unit tests
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 07 Dec 2011 17:24:37 +0100 |
parents | f0afece42f48 |
children |
line wrap: on
line source
function executeConstants(varargin) wb = varargin{1}; if isa(wb, 'LTPDAworkbench') consts = awtinvoke(wb.mp, 'getAllConstants'); elseif isa(wb, 'mpipeline.canvas.MCanvas') consts = wb.getAllConstants; else error('Unknown input object'); end % Then execute all constants for kk=1:consts.size() c = consts.get(kk-1); if ~c.isCommentedOut varname = char(c.getName()); expr = char(c.getExpression()); if exist(varname) > 1 || ~isvarname(varname) error('The constant block named "%s" is not a valid variable name. \nPlease rename it.', varname); end % can the expression be evaluated, or is it a string? try eval([expr ';']); cmd = [varname ' = ' expr ';']; catch cmd = [varname ' = ''' expr ''';']; end % evaluate disp(sprintf('++ preparing variable: %s', cmd)); evalin('base', cmd); else varname = char(c.getName()); cmd = ['clear ', varname]; evalin('base', cmd); end end end