Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: ea0818 on June 27, 2023, 03:17:01 am
-
I need to do a loop in a transform template. For example a for...next or a while loop.
I found the EA documentation for the macros at https://sparxsystems.com/enterprise_architect_user_guide/15.2/model_domains/macros.html
In particular branching, such as if or elseIf, is found at https://sparxsystems.com/enterprise_architect_user_guide/15.2/model_domains/branching_macros.html
But I don't see any macro for repeating a set of instructions. Best I can think of is to write a custom transform template, and then repeatedly call it from the main transform template. One of the parameters would indicate what iteration in the loop is to be processed during this execution.
This would be an ugly solution though, as I would need to repeat the call (from the main template) as many times as needed, such as:
$remark="Perform the ten iterations"
%DoLoopWork(1)%
%DoLoopWork(2)%
%DoLoopWork(3)%
%DoLoopWork(4)%
%DoLoopWork(5)%
%DoLoopWork(6)%
%DoLoopWork(7)%
%DoLoopWork(8)%
%DoLoopWork(9)%
%DoLoopWork(10)%
Anyone have a better idea?
-
I'm not getting tired of repeating it: write your own transformation (/code generation) using the API. More flexibilty and you use the language you're familiar with, not some DSL only a Sparxian can understand.
q.
-
Yes, the language, macros and syntax rules used in the transform templates are not easy to work with. I found it quite frustrating. Something as simple as combining an "if" with a math operation (e.g. %if $a == Math_Add(2, 3)%) is not allowed.
But I started with the transform templates that were supplied, and made fixes and enhancements. And at this point, it will be far less work to just add to the existing templates than to re-write everything in another language.
Anyone know a way to do a for...next loop in the transform templates?
-
Good luck in fighting the windmills, D.Q.
q.