Mercurial > hg > ltpda
comparison m-toolbox/classes/@LTPDAworkbench/executeConstants.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 function executeConstants(varargin) | |
2 | |
3 wb = varargin{1}; | |
4 | |
5 if isa(wb, 'LTPDAworkbench') | |
6 consts = awtinvoke(wb.mp, 'getAllConstants'); | |
7 elseif isa(wb, 'mpipeline.canvas.MCanvas') | |
8 consts = wb.getAllConstants; | |
9 else | |
10 error('Unknown input object'); | |
11 end | |
12 | |
13 % Then execute all constants | |
14 for kk=1:consts.size() | |
15 | |
16 c = consts.get(kk-1); | |
17 if ~c.isCommentedOut | |
18 varname = char(c.getName()); | |
19 expr = char(c.getExpression()); | |
20 | |
21 if exist(varname) > 1 || ~isvarname(varname) | |
22 error('The constant block named "%s" is not a valid variable name. \nPlease rename it.', varname); | |
23 end | |
24 | |
25 % can the expression be evaluated, or is it a string? | |
26 try | |
27 eval([expr ';']); | |
28 cmd = [varname ' = ' expr ';']; | |
29 catch | |
30 cmd = [varname ' = ''' expr ''';']; | |
31 end | |
32 | |
33 % evaluate | |
34 disp(sprintf('++ preparing variable: %s', cmd)); | |
35 evalin('base', cmd); | |
36 else | |
37 varname = char(c.getName()); | |
38 cmd = ['clear ', varname]; | |
39 evalin('base', cmd); | |
40 end | |
41 end | |
42 | |
43 end |