Book a Demo

Author Topic: Tutorial on Macros ?  (Read 2981 times)

JohnDoe

  • EA User
  • **
  • Posts: 191
  • Karma: +0/-0
  • EA rocks !
    • View Profile
Tutorial on Macros ?
« on: October 01, 2006, 01:38:29 pm »
Hello,

is there any tutorial available explaining how to create "macros" for the simple minded (=me) ?

I understand so far that templates create models in EA (if I take JUnit, Java etc. I get nice classes). But how do I interpret this text below ? Where can or should I change it ?

[...]
%elemType%
{
 %TRANSFORM_REFERENCE("Class")%
 %TRANSFORM_CURRENT()%
%list="ClassParameter" @separator="\n" @indent="    "%
%list="ClassBase" @separator="\n" @indent="  "%
%list="ClassInterface" @separator="\n" @indent="  "%
%list="InnerClass" @separator="\n" @indent="  "%
%list="Attribute" @separator="\n" @indent="  "%
%list="Operation" @separator="\n" @indent="  "%
}
%list="Connector" @separator="\n"%
[...]

No matter what I typed in, I only get syntax errors when I transform my classes using the altered template afterwards.

Though looking at the builtin documentation, I dont understand how to adapt the generation template macros  (I have copied a generation template and now I want to change the template for creating Actionscript TestClasses by copying a package and then duplicating and renaming classes e.g. from "Account" to "AccountTest" and duplicating the methods of the initial class from "calculate" to "test_calculate"). I am stuck here. Any help or pointing to a tutorial is welcome.

Thanks in advance
Bernd
« Last Edit: October 01, 2006, 01:50:58 pm by BerndWill »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Tutorial on Macros ?
« Reply #1 on: October 01, 2006, 05:16:52 pm »
Try reading the comments at the top of the default transformation templates (EA 6.5) and looking at the help for writing transformations. http://www.sparxsystems.com.au/EAUserGuide/index.html?writingtransformations.htm

It would probably help to know what you typed to get the parse errors, but the key to what you're doing is the TRANSFORM_CURRENT macro.

You'll want it to not copy the name over and instead specify the name yourself.

eg.
Code: [Select]
%TRANSFORM_CURRENT("name")%
name=%qt%%className%Test%qt%

and
Code: [Select]
%TRANSFORM_CURRENT("name")%
name=%qt%test_%opName%%qt%

That should get you going.
« Last Edit: October 01, 2006, 05:17:22 pm by simonm »