Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Does the Acceleo Language support constants?
[Acceleo] Does the Acceleo Language support constants? [message #701821] Mon, 25 July 2011 16:26 Go to next message
Tomas Balderas is currently offline Tomas BalderasFriend
Messages: 64
Registered: July 2010
Member
Hello everybody

I need to use some string values in more than one module (.mtl file) in my project. I am looking for a way to define macros or constants in a single place and use them in multiple places (much like the #define directive of C's preprocessor). I checked let blocks, but I don't think the variables defined by them can be used in different modules. I think that defining a number of queries each returning the appropriate value would be a way to centralize the definition of a fixed value that can be used in multiple modules, but doesn't seem too elegant to me.

Does any expert in Acceleo know about a way to define constants?

Thanks. Kindest regards.


/TB
(no subject) [message #701835 is a reply to message #701821] Mon, 25 July 2011 16:55 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

You can define an additional Constants.ecore meta-model with all your
favourite valiures in.

Regards

Ed Willink

On 25/07/2011 17:26, Balderas wrote:
> Hello everybody
>
> I need to use some string values in more than one module (.mtl file)
> in my project. I am looking for a way to define macros or constants in
> a single place and use them in multiple places (much like the #define
> directive of C's preprocessor). I checked let blocks, but I don't
> think the variables defined by them can be used in different modules.
> I think that defining a number of queries each returning the
> appropriate value would be a way to centralize the definition of a
> fixed value that can be used in multiple modules, but doesn't seem too
> elegant to me.
>
> Does any expert in Acceleo know about a way to define constants?
>
> Thanks. Kindest regards.
Re: (no subject) [message #702328 is a reply to message #701835] Tue, 26 July 2011 08:17 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
Hi,

Defining a set of queries returning the accurate String in their own module sure is one way to do it, but it does not seem like the easiest. If what you need are String constants, then the best way would be to define them in a properties file, and use these properties directly from your Acceleo module.

Stéphane had written a good post about how to use properties files with Acceleo 3.1 on his blog.

I'll only add that to access properties from an Acceleo module after you've followed his steps, you need to use one of the "getProperty" services the Acceleo syntax provides. See their definitions on the Acceleo operations reference.

Laurent Goubet
Obeo
Previous Topic:[ACCELEO] How to make Acceleo to use my model?
Next Topic:[MWE] Use metamodel from other plugin
Goto Forum:
  


Current Time: Thu Apr 18 03:05:08 GMT 2024

Powered by FUDForum. Page generated in 0.02083 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top