view m-toolbox/classes/@LTPDAworkbench/executeConstants.m @ 27:29276498ebdb
database-connection-manager
Remove LTPDARepositoryManager implementation
* * *
Remove GUI helper
author |
Daniele Nicolodi <nicolodi@science.unitn.it> |
date |
Mon, 05 Dec 2011 16:20:06 +0100 (2011-12-05) |
parents |
f0afece42f48 |
children |
|
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